@lakutata/cli 3.0.0-beta.3 → 3.0.0-beta.5
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 +45 -4
- package/dist/esm/controllers/PackController.js +16 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -212,6 +212,44 @@ 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 files the application reads by their paths are not followed by the bundler: the scripts it runs on their own (its
|
|
216
|
+
workers, `new Worker()`, the pools of workers given a file; its child processes, `fork()`; the modules it loads by their
|
|
217
|
+
paths, `require(path.join(__dirname, 'x.js'))`), its data (`fs.readFileSync(path.join(__dirname, 'defaults.json'))`, a
|
|
218
|
+
directory of schemas). And the bundle is not where its modules were: `path.resolve(__dirname, '../../schema')` of a
|
|
219
|
+
module of `build/config/` is the `schema/` of the project, not once bundled in `dist/`. A path to a file given from its
|
|
220
|
+
module is found wherever it is written, in the modules of the application and in the ones of its packages, and the
|
|
221
|
+
expression rewritten to the file in the native tree (`dist/<name>.native/.lakutata/files/`, the directories as in the
|
|
222
|
+
project, the packages linked from outside of it under `node_modules/`):
|
|
223
|
+
|
|
224
|
+
| The path names | |
|
|
225
|
+
|---|---|
|
|
226
|
+
| a script (`.js`, `.cjs`) | bundled on its own with what it loads (a CommonJS file, whatever the type of the project) |
|
|
227
|
+
| another file | copied (a `package.json` its type CommonJS, as the scripts next to it) |
|
|
228
|
+
| a directory of data | its files copied |
|
|
229
|
+
| a directory holding the module (`path.join(__dirname, '..')`: the application, its packages) | not shipped, warned of: its files are declared as resources (`lakutata.resources`, below) |
|
|
230
|
+
| a directory holding scripts or packages (`package.json`, `node_modules`) | not shipped, warned of: its scripts need their packages at run time |
|
|
231
|
+
| nothing yet (a directory the application creates) | left as it is |
|
|
232
|
+
|
|
233
|
+
The paths followed:
|
|
234
|
+
|
|
235
|
+
| Path | |
|
|
236
|
+
|---|---|
|
|
237
|
+
| `new URL('./worker.js', import.meta.url)` | the URL of the module (as Vite); `pathToFileURL(__filename)` too |
|
|
238
|
+
| `import.meta.url + '/../worker.js'` | a text of the URL of the module |
|
|
239
|
+
| `path.join(__dirname, 'worker.js')`, `path.resolve(__dirname, …)` | `import.meta.dirname`, `path.dirname(fileURLToPath(import.meta.url))` too |
|
|
240
|
+
| `__dirname + '/worker.js'`, `` `${__dirname}/worker.js` `` | |
|
|
241
|
+
| `require.resolve('./worker')`, `require.resolve(path.resolve(__dirname, '../lib/worker'))` | the extension found as node finds it |
|
|
242
|
+
| `` path.join(__dirname, 'locales', `${lang}.json`) ``, `` new URL(`./jobs/${name}.js`, import.meta.url) `` | known in part: every file and directory its pattern matches (an expression matches a part of a name), its expression kept |
|
|
243
|
+
|
|
244
|
+
The code of tsc (`(0, node_path_1.join)(__dirname, 'worker.js')`) is followed. A script also imported by the application
|
|
245
|
+
is warned of: it is bundled twice, its module apart in each (its state, its classes). The workers of node
|
|
246
|
+
(`worker_threads`) whose scripts cannot be followed are warned of with their file and line, in the modules of the
|
|
247
|
+
application (the packages start workers from the paths their users give): a path known at run time only
|
|
248
|
+
(`new Worker(file)`, a variable or a property of a class holding one of the paths above is followed), or a path relative
|
|
249
|
+
to the current directory of the process (`new Worker('./worker.js')`, which node reads from there, not from the module);
|
|
250
|
+
their scripts are given from the directory of their module, or shipped as resources. The workers running a source
|
|
251
|
+
(`eval: true`) need nothing. The warnings name the modules of the application only, with their file and line.
|
|
252
|
+
|
|
215
253
|
The resources of the application, the files it reads at run time (the built pages of a web application, templates,
|
|
216
254
|
data), are declared by the `lakutata.resources` of its `package.json`, as the `extraResources` of electron-builder:
|
|
217
255
|
|
|
@@ -250,11 +288,14 @@ linux/arm64`, as the cross builds of the templates).
|
|
|
250
288
|
| `--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
289
|
| `--entry`, `--no-minify`, `--external` | as `lakutata package bundle` |
|
|
252
290
|
|
|
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),
|
|
291
|
+
The native addons, the files read by their paths and the resources are embedded in the executable (`--layout file`): at its
|
|
292
|
+
first run, it extracts them into its cache directory (`~/.cache/<name>`, `~/Library/Caches/<name>` on macOS,
|
|
293
|
+
`%LOCALAPPDATA%\<name>\Cache` on Windows, or `LAKUTATA_NATIVE_DIR`; the temporary directory when it cannot be written),
|
|
294
|
+
in a directory named after their content:
|
|
256
295
|
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).
|
|
296
|
+
glibc version of the Linux prebuilt addons). The child processes of an executable run it (`process.execPath`): started
|
|
297
|
+
for one of its scripts (`fork(path.join(__dirname, 'child.js'))`, `spawn(process.execPath, [script])`), it runs the
|
|
298
|
+
script as node does (its arguments, `require.main`), not the application.
|
|
258
299
|
|
|
259
300
|
The executables of macOS are signed ad hoc. The ones of Windows made by Node.js keep the signature of `node.exe`, which
|
|
260
301
|
does not match anymore: sign them before distributing them.
|
|
@@ -31,11 +31,20 @@ 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 = [
|
|
38
|
+
...addons ? [`the native addons (${result.native.modules.join(', ') || 'of the application'})`] : [],
|
|
39
|
+
...result.workers.length ? [`the scripts run on their own (${result.workers.join(', ')})`] : [],
|
|
40
|
+
...result.files.length ? [`the files read by their paths (${result.files.join(', ')})`] : []
|
|
41
|
+
];
|
|
42
|
+
done(`${path.relative(process.cwd(), result.nativeDirectory)}: ${contents.join(' and ')}, distributed with the bundle`);
|
|
43
|
+
}
|
|
37
44
|
if (result.resourcesDirectory)
|
|
38
45
|
done(`${path.relative(process.cwd(), result.resourcesDirectory)}: the resources (${result.resources.join(', ')}), distributed with the bundle`);
|
|
46
|
+
for (const warning of result.warnings)
|
|
47
|
+
warn(warning);
|
|
39
48
|
return undefined;
|
|
40
49
|
}
|
|
41
50
|
async executable(input) {
|
|
@@ -46,6 +55,10 @@ export class PackController extends Controller {
|
|
|
46
55
|
step(result.directory ? `Native addons next to the executable: ${result.native.join(', ')}` : `Native addons embedded, extracted at the first run: ${result.native.join(', ')}`);
|
|
47
56
|
if (result.resources.length)
|
|
48
57
|
step(result.directory ? `Resources next to the executable: ${result.resources.join(', ')}` : `Resources embedded, extracted at the first run: ${result.resources.join(', ')}`);
|
|
58
|
+
if (result.workers.length)
|
|
59
|
+
step(result.directory ? `Scripts run on their own next to the executable: ${result.workers.join(', ')}` : `Scripts run on their own embedded, extracted at the first run: ${result.workers.join(', ')}`);
|
|
60
|
+
if (result.files.length)
|
|
61
|
+
step(result.directory ? `Files read by their paths next to the executable: ${result.files.join(', ')}` : `Files read by their paths embedded, extracted at the first run: ${result.files.join(', ')}`);
|
|
49
62
|
for (const warning of result.warnings)
|
|
50
63
|
warn(warning);
|
|
51
64
|
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.5",
|
|
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.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@lakutata/builder": "3.0.0-beta.
|
|
22
|
+
"@lakutata/builder": "3.0.0-beta.5"
|
|
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.5"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=22.12"
|