Why my file is not added to the appImage (electron app) - linux

I have an electron app which uses a database opened with the following code:
const fs = require("fs")
const sqlite = require("aa-sqlite")
await sqlite.open('cregr_db.db');
My package.json contains :
"build": {
"appId": "crergr",
"linux": {
"target": [
"AppImage"
],
"icon": "icon512.png"
},
"win": {
"target": "NSIS",
"icon": "icon256.ico"
},
"extraFiles": [
"cregr_db.db"
]
},
the cregr_db.db is in the same folder as my *js, index.html and style.css.
Everything runs fine when launched from the root directory of my app.
If I run the app image from elsewhere, I have an exception when I query the database and, in fact, the database file is not displayed in the file hierarchy.
I can not post an image here but you can find one at http://alainbe.free.fr/files.png
What I am doing wrong ?
Thanks for your help.

In fact, the db file was probably added but in an ASAR archive so can't be read by the code posted above.
The solution I chose was to distribute the app without building an ASAR archive and in this case, everything works exactly like you are testing your app (tested on Linux and Windows).
There is a strong warning about building an app without an ASAR. I chose not to pay attention because any way there are ways to unpack the ASAR and see the code and besides, my app is GPL'ed.

Related

change the path of asset files in jest

So I want to run an e2e test using jest. I'm using nx monorepo architecture, and I have all my assets in a library folder and also nestjs microservices for my backend. I have all my proto files for my microservices in the library, and when I want to load them in my microservices, I do it like this :
protoPath: join(__dirname, 'assets-shared/job.proto'),
and in my workspace.json in my build i change the assets-shared like this:
"targets": {
"build": {
"options": {
"assets": [
{
"input": "libs/backend/shared/src/lib/assets",
"glob": "**/*",
"output": "assets-shared"
}
]
},
all is good, but when I run the test and when it wants to import and give value to it, it doesn't change it, and I have this error which is trying in its folder and not the library folder
ENOENT: no such file or directory, open '/home/dev/Project/apps/backend/api/src/modules/product/assets-shared/job.proto'
I tried the moduleNameMapper to give the libs folder to it manually but no avail.
moduleNameMapper: {
'^.+\\.(proto)$':
'<rootDir>/libs/backend/shared/src/lib/assets/$1',
// '^assets-shared(.*)': '/libs/backend/shared/src/lib/assets/$1',
},
non of these two worked
Have you considered publishing the libraries to a private npm repository or something like artifactory e.g. #my-company/assets
The approach you are trying may work locally, but for a ci/cd pipeline it would be much better to have a versioned artifact in npm or artifactory

Monaco-Editor fails on oracle jet build/serve when in release mode

I'm trying to implement the Monaco editor within my oracle jet web application. I've tried with the dev and min folders. It works fine when I run serve without the release mode option but when I include --release on build or serve it is throwing the below error
Error: ENOENT: no such file or directory, open '/web/js/libs/vs/editor/edcore.main.js'
I'm not sure why Monaco is needing the file as that file is not included in either the dev or min folders but it is referenced in the "vs/editor/editor.main.js" file and that is where the error is coming from.
Within Oracle Jet for Require JS the info is stored in the path mapping json as follows :
"vs": {
"cdn": "3rdparty",
"cwd": "node_modules/monaco-editor/dev/vs",
"debug": {
"src": ["**"],
"path": "libs/vs/",
"cdnPath": ""
},
"release": {
"src": ["**"],
"path": "libs/vs",
"cdnPath": ""
}
},
Again, everything is perfect when not optimized into a single js file in the browser using the release option
You should remove the monaco editor library from the optimization.
Add to your before_optimize hook:
configObj.componentRequireJs.paths['vs'] = 'empty:';
configObj.requireJs.paths['vs'] = 'empty:';

Trying to share code from Hyperapp with Bit.dev

I'm trying to share my code from my front (hyperapp) to my admin (hyperapp to) to make "preview" button.
The setup of these projects was made by an other dev, so i had to learn hyperapp workflow on the job, i'm not expert.
From what i know he was inspired by Facebook React conf.
All my usefull code is in src/ folder, and there is many dependencies so i have to export all (api, constants, utils, etc..).
Here is my bit configuration (that work, it export code correctly):
"bit": {
"env": {
"compiler": "bit.envs/compilers/react#1.0.2"
},
"packageManager": "yarn",
"packageManagerArgs": [
"--production",
"--no-optional"
],
"packageManagerProcessOptions": {
"shell": true
},
"resolveModules": {
"modulesDirectories": [
"src"
]
},
"dist": {
"entry": "src",
"target": "dist"
}
}
So, the code is "correctly" exported to bit.dev, but, when i import it from my admin with
"#bit/adrienbelair.betterise-web.modules": "^0.3.0",
i get the following error after running yarn:
yarn install
ls: Command failed.
Exit code: 1
Command: node .bit.postinstall.js
...
Error: ENOTDIR: not a directory, mkdir 'node_modules/utils/HOA'
Yes, if i look into node_module, utils is a file, and not a directory
All these are auto-generated, i dont understand what am i doing wrong?
Second thing, probably from this above error, when i try to import a component (even if there is an error, vendor are downloaded and at their place), i get:
import { Advice } from '#bit/adrienbelair.betterise-web.modules/dist/modules';
./node_modules/#bit/adrienbelair.betterise-web.api/controlleur.js
Module not found: Can't resolve 'api' in '/Users/prinzivalle/Web/betterise/admin-front/node_modules/#bit/adrienbelair.betterise-web.api'
From this line (if i look into node_module, where the error is thrown):
import { User, Cardline } from 'api';
I know, its a very specific case, mine, but i dont find any forum or explicit tutorial. Only some little component export with not a lot of dependencies.
I made my code with a little knowledge of Hyperapp/React and without thinking about sharing it one day..
Thank for reading.

Yoga server deployment to the now.sh shows directory listing instedad the application

I can run the app locally without any issue by yarn start command. here I have provided photographs which represent my problem. I googled and noticed several people faces the same problem. but their context is different.
By default, Now publishes your files as a static directory. You can add a builder to your now.json file to tell Now how to build and deploy your site.
In a case where app.js contains a web server application, your now.json might look like this:
{
"version": 2,
"name": "my-project",
"builds": [
{"src": "app.js", "use": "#now/node"}
]
}
This tells Now to use the #now/node builder to generate a lambda that runs app.js to respond to requests.
If your app is purely js+html to be run on the client machine, you wouldn't need the lambda, but you can still build the source before deploying it as static files with #now/static-build.
Check out the Now docs for more info: https://zeit.co/docs/v2/deployments/basics/#introducing-a-build-step

UnauthorizedAccessException for static files when using IIS

I am developing a web application using ASP.Net core MVC. Initially to get started I manually copied the bootstrap and jQuery directly under wwwroot/lib folder. This worked fine.
To make the code maintainable, I thought it would be better to use client side library manager like libman.
This is what I have got in libman.json
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"library": "bootstrap#4.1.3",
"destination": "wwwroot/lib/bootstrap/"
},
{
"provider": "cdnjs",
"library": "jquery#3.3.1",
"destination": "wwwroot/lib/jquery/"
}
]
}
When I restore the client side library, I can see the files correctly restored under lib folder
Now when I compile and test the app locally using IIS, I am getting 500 error in developer tools while fetching bootstrap.css, jquery.js and bootstrap.js
When I tried to load bootstrap.css directly, I get 500 and message that access to the file is denied
UnauthorizedAccessException: Access to the path 'C:\code\wwwroot\lib\bootstrap\dist\css\bootstrap.css' is denied.
Any thoughts what would be causing this error?

Resources