@lakutata/cli 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/dist/esm/controllers/PackController.js +10 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -212,6 +212,33 @@ files by paths which cannot be followed (`require(path.join(__dirname, name))`)
|
|
|
212
212
|
maps, the TypeScript sources and the documentation of the packages are left out. The addons of
|
|
213
213
|
the application itself (`require('./x.node')`, `createRequire(import.meta.url)('./x.node')`) are there too.
|
|
214
214
|
|
|
215
|
+
The scripts the application runs on their own by their paths are not followed by the bundler: the scripts of its
|
|
216
|
+
workers (`new Worker()`, the pools of workers given a file), of its child processes (`fork()`), the modules it loads by
|
|
217
|
+
their paths (`require(path.join(__dirname, 'x.js'))`). A path to a script (a `.js` or `.cjs` file) given from its module
|
|
218
|
+
is found wherever it is written, in the modules of the application and in the ones of its packages (the scripts of the
|
|
219
|
+
pools of workers): the script is bundled on its own with what it loads (a CommonJS file, whatever the type of the
|
|
220
|
+
project) into the native tree (`dist/<name>.native/.lakutata/workers/`, its directories as in the project, the packages
|
|
221
|
+
linked from outside of it under `node_modules/`), and the expression rewritten to it. The paths followed:
|
|
222
|
+
|
|
223
|
+
| Path | |
|
|
224
|
+
|---|---|
|
|
225
|
+
| `new URL('./worker.js', import.meta.url)` | the URL of the module (as Vite); `pathToFileURL(__filename)` too |
|
|
226
|
+
| `import.meta.url + '/../worker.js'` | a text of the URL of the module |
|
|
227
|
+
| `path.join(__dirname, 'worker.js')`, `path.resolve(__dirname, …)` | `import.meta.dirname`, `path.dirname(fileURLToPath(import.meta.url))` too |
|
|
228
|
+
| `__dirname + '/worker.js'`, `` `${__dirname}/worker.js` `` | |
|
|
229
|
+
| `require.resolve('./worker')`, `require.resolve(path.resolve(__dirname, '../lib/worker'))` | the extension found as node finds it |
|
|
230
|
+
| `` path.join(__dirname, 'jobs', `${name}.js`) ``, `` new URL(`./jobs/${name}.js`, import.meta.url) `` | known in part: every script of the directory its pattern matches (an expression matches a part of a name), its expression kept |
|
|
231
|
+
|
|
232
|
+
The code of tsc (`(0, node_path_1.join)(__dirname, 'worker.js')`) is followed. The paths to other files (a directory, a
|
|
233
|
+
data file) are left as they are: they are resources (below). A script also imported by the application is warned of:
|
|
234
|
+
it is bundled twice, its module apart in each (its state, its classes). The workers of node (`worker_threads`) whose
|
|
235
|
+
scripts cannot be followed are warned of with their file and line, in the modules of the application (the packages start
|
|
236
|
+
workers from the paths their users give): a path known at run time only (`new Worker(file)`, a variable or a property of
|
|
237
|
+
a class holding one of the paths above is followed), or a path relative to the current directory of the process
|
|
238
|
+
(`new Worker('./worker.js')`, which node reads from there, not from the module); their scripts are given from the
|
|
239
|
+
directory of their module, or shipped as resources (`lakutata.resources`). The workers running a source (`eval: true`)
|
|
240
|
+
need nothing.
|
|
241
|
+
|
|
215
242
|
The resources of the application, the files it reads at run time (the built pages of a web application, templates,
|
|
216
243
|
data), are declared by the `lakutata.resources` of its `package.json`, as the `extraResources` of electron-builder:
|
|
217
244
|
|
|
@@ -250,11 +277,14 @@ linux/arm64`, as the cross builds of the templates).
|
|
|
250
277
|
| `--layout <file\|directory>` | one file (by default), or a directory: `dist/<name>/` holding the executable, its native addons (`native/`) and its resources (`resources/`), loaded from there without extraction (the installers, the images) |
|
|
251
278
|
| `--entry`, `--no-minify`, `--external` | as `lakutata package bundle` |
|
|
252
279
|
|
|
253
|
-
The native addons and the resources are embedded in the executable (`--layout file`): at its
|
|
254
|
-
into its cache directory (`~/.cache/<name>`, `~/Library/Caches/<name>` on macOS,
|
|
255
|
-
or `LAKUTATA_NATIVE_DIR`; the temporary directory when it cannot be written),
|
|
280
|
+
The native addons, the scripts of the workers and the resources are embedded in the executable (`--layout file`): at its
|
|
281
|
+
first run, it extracts them into its cache directory (`~/.cache/<name>`, `~/Library/Caches/<name>` on macOS,
|
|
282
|
+
`%LOCALAPPDATA%\<name>\Cache` on Windows, or `LAKUTATA_NATIVE_DIR`; the temporary directory when it cannot be written),
|
|
283
|
+
in a directory named after their content:
|
|
256
284
|
the next runs load them from there, the versions of the program do not share it. The addons need the system libraries they were built for (the
|
|
257
|
-
glibc version of the Linux prebuilt addons).
|
|
285
|
+
glibc version of the Linux prebuilt addons). The child processes of an executable run it (`process.execPath`): started
|
|
286
|
+
for one of its scripts (`fork(path.join(__dirname, 'child.js'))`, `spawn(process.execPath, [script])`), it runs the
|
|
287
|
+
script as node does (its arguments, `require.main`), not the application.
|
|
258
288
|
|
|
259
289
|
The executables of macOS are signed ad hoc. The ones of Windows made by Node.js keep the signature of `node.exe`, which
|
|
260
290
|
does not match anymore: sign them before distributing them.
|
|
@@ -31,11 +31,16 @@ export class PackController extends Controller {
|
|
|
31
31
|
const { bundleProject } = await loadBuilder(process.cwd());
|
|
32
32
|
const result = await bundleProject({ project: process.cwd(), entry: input.entry, outfile: input.outfile, minify: input.minify, external: input.external });
|
|
33
33
|
done(`${path.relative(process.cwd(), result.outfile)} (${megabytes(result.size)}): node ${path.relative(process.cwd(), result.outfile)}`);
|
|
34
|
-
//The native addons are next to the bundle, which is distributed with them
|
|
35
|
-
if (result.nativeDirectory)
|
|
36
|
-
|
|
34
|
+
//The native addons and the scripts of the workers are next to the bundle, which is distributed with them
|
|
35
|
+
if (result.nativeDirectory) {
|
|
36
|
+
const addons = !!result.native.modules.length || result.native.files.some((file) => file.path.endsWith('.node'));
|
|
37
|
+
const contents = [...addons ? [`the native addons (${result.native.modules.join(', ') || 'of the application'})`] : [], ...result.workers.length ? [`the scripts of the workers (${result.workers.join(', ')})`] : []];
|
|
38
|
+
done(`${path.relative(process.cwd(), result.nativeDirectory)}: ${contents.join(' and ')}, distributed with the bundle`);
|
|
39
|
+
}
|
|
37
40
|
if (result.resourcesDirectory)
|
|
38
41
|
done(`${path.relative(process.cwd(), result.resourcesDirectory)}: the resources (${result.resources.join(', ')}), distributed with the bundle`);
|
|
42
|
+
for (const warning of result.warnings)
|
|
43
|
+
warn(warning);
|
|
39
44
|
return undefined;
|
|
40
45
|
}
|
|
41
46
|
async executable(input) {
|
|
@@ -46,6 +51,8 @@ export class PackController extends Controller {
|
|
|
46
51
|
step(result.directory ? `Native addons next to the executable: ${result.native.join(', ')}` : `Native addons embedded, extracted at the first run: ${result.native.join(', ')}`);
|
|
47
52
|
if (result.resources.length)
|
|
48
53
|
step(result.directory ? `Resources next to the executable: ${result.resources.join(', ')}` : `Resources embedded, extracted at the first run: ${result.resources.join(', ')}`);
|
|
54
|
+
if (result.workers.length)
|
|
55
|
+
step(result.directory ? `Scripts of the workers next to the executable: ${result.workers.join(', ')}` : `Scripts of the workers embedded, extracted at the first run: ${result.workers.join(', ')}`);
|
|
49
56
|
for (const warning of result.warnings)
|
|
50
57
|
warn(warning);
|
|
51
58
|
if (result.directory)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lakutata/cli",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "The command line tool of the lakutata framework: create the projects from the templates, run and version the packages of the workspaces, bundle the applications and make their executables (with @lakutata/builder).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@inquirer/prompts": "^8.7.2",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
|
-
"lakutata": "3.0.0-beta.
|
|
19
|
+
"lakutata": "3.0.0-beta.4"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@lakutata/builder": "3.0.0-beta.
|
|
22
|
+
"@lakutata/builder": "3.0.0-beta.4"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"@lakutata/builder": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@lakutata/builder": "3.0.0-beta.
|
|
30
|
+
"@lakutata/builder": "3.0.0-beta.4"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=22.12"
|