@codenotch/codenotch.cli 1.0.39 → 1.0.41
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/dist/commands/generate/app.js +13 -2
- package/dist/commands/generate/app.js.map +1 -1
- package/dist/commands/generate/appmanifest.js +52 -3
- package/dist/commands/generate/appmanifest.js.map +1 -1
- package/dist/commands/generate/dbcontext.js +5 -1
- package/dist/commands/generate/dbcontext.js.map +1 -1
- package/dist/commands/generate/i18n.d.ts +1 -1
- package/dist/commands/generate/i18n.js +53 -10
- package/dist/commands/generate/i18n.js.map +1 -1
- package/dist/commands/generate/index.js +11 -2
- package/dist/commands/generate/index.js.map +1 -1
- package/dist/commands/generate/manifest.js +4 -0
- package/dist/commands/generate/manifest.js.map +1 -1
- package/dist/commands/generate/openapi.js +5 -1
- package/dist/commands/generate/openapi.js.map +1 -1
- package/dist/commands/generate/pkg.js +4 -0
- package/dist/commands/generate/pkg.js.map +1 -1
- package/dist/commands/generate/process.d.ts +2 -0
- package/dist/commands/generate/process.js +151 -0
- package/dist/commands/generate/process.js.map +1 -0
- package/dist/commands/project/index.js +8 -1
- package/dist/commands/project/index.js.map +1 -1
- package/dist/commands/project/new.js +16 -3
- package/dist/commands/project/new.js.map +1 -1
- package/dist/commands/project/remove.js +17 -1
- package/dist/commands/project/remove.js.map +1 -1
- package/dist/commands/react/build.js +22 -1
- package/dist/commands/react/build.js.map +1 -1
- package/dist/commands/react/clean.js +7 -2
- package/dist/commands/react/clean.js.map +1 -1
- package/dist/commands/react/dev.js +6 -0
- package/dist/commands/react/dev.js.map +1 -1
- package/dist/commands/react/index.js +11 -1
- package/dist/commands/react/index.js.map +1 -1
- package/dist/commands/react/package.d.ts +2 -0
- package/dist/commands/react/package.js +47 -0
- package/dist/commands/react/package.js.map +1 -0
- package/dist/commands/react/serve.js +5 -0
- package/dist/commands/react/serve.js.map +1 -1
- package/dist/commands/react/shared.js +1 -2
- package/dist/commands/react/shared.js.map +1 -1
- package/dist/commands/runtime/clear.js +15 -1
- package/dist/commands/runtime/clear.js.map +1 -1
- package/dist/commands/runtime/index.js +8 -1
- package/dist/commands/runtime/index.js.map +1 -1
- package/dist/commands/validation/ValidationUtils.js +1 -1
- package/dist/commands/validation/ValidationUtils.js.map +1 -1
- package/dist/commands/validation/files/I18nValidator.js +0 -9
- package/dist/commands/validation/files/I18nValidator.js.map +1 -1
- package/dist/commands/validation/files/ScriptValidator.js +6 -5
- package/dist/commands/validation/files/ScriptValidator.js.map +1 -1
- package/dist/commands/validation/validate.js +4 -13
- package/dist/commands/validation/validate.js.map +1 -1
- package/dist/utils/BuildUtils.d.ts +55 -5
- package/dist/utils/BuildUtils.js +238 -21
- package/dist/utils/BuildUtils.js.map +1 -1
- package/dist/utils/ConsoleUtils.d.ts +5 -2
- package/dist/utils/ConsoleUtils.js +20 -8
- package/dist/utils/ConsoleUtils.js.map +1 -1
- package/dist/utils/OsUtils.d.ts +6 -0
- package/dist/utils/OsUtils.js +26 -0
- package/dist/utils/OsUtils.js.map +1 -1
- package/dist/utils/PackageUtils.d.ts +101 -0
- package/dist/utils/PackageUtils.js +538 -0
- package/dist/utils/PackageUtils.js.map +1 -0
- package/dist/utils/ProcessModelUtils.d.ts +38 -0
- package/dist/utils/ProcessModelUtils.js +254 -0
- package/dist/utils/ProcessModelUtils.js.map +1 -0
- package/dist/utils/ProjectCompilationUtils.js.map +1 -1
- package/dist/utils/ServeUtils.js +1 -2
- package/dist/utils/ServeUtils.js.map +1 -1
- package/dist/utils/TemplateUtils.d.ts +1 -0
- package/dist/utils/TemplateUtils.js +21 -3
- package/dist/utils/TemplateUtils.js.map +1 -1
- package/package.json +1 -1
package/dist/utils/OsUtils.d.ts
CHANGED
|
@@ -5,4 +5,10 @@ export declare class OsUtils {
|
|
|
5
5
|
* @param url The URL to open.
|
|
6
6
|
*/
|
|
7
7
|
static openInBrowser(url: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Opens a folder in the file explorer of the system (Explorer, Finder, the desktop file manager).
|
|
10
|
+
* Supports Windows, macOS and Linux.
|
|
11
|
+
* @param folderPath The folder to open.
|
|
12
|
+
*/
|
|
13
|
+
static openInFileExplorer(folderPath: string): void;
|
|
8
14
|
}
|
package/dist/utils/OsUtils.js
CHANGED
|
@@ -28,6 +28,32 @@ class OsUtils {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Opens a folder in the file explorer of the system (Explorer, Finder, the desktop file manager).
|
|
33
|
+
* Supports Windows, macOS and Linux.
|
|
34
|
+
* @param folderPath The folder to open.
|
|
35
|
+
*/
|
|
36
|
+
static openInFileExplorer(folderPath) {
|
|
37
|
+
let command;
|
|
38
|
+
switch (process.platform) {
|
|
39
|
+
case 'win32':
|
|
40
|
+
command = `explorer "${folderPath}"`;
|
|
41
|
+
break;
|
|
42
|
+
case 'darwin':
|
|
43
|
+
command = `open "${folderPath}"`;
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
// Linux and other Unix-like systems
|
|
47
|
+
command = `xdg-open "${folderPath}"`;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
(0, child_process_1.exec)(command, (error) => {
|
|
51
|
+
// explorer.exe leaves a non-zero exit code even when the window did open: only report elsewhere
|
|
52
|
+
if (error && process.platform !== 'win32') {
|
|
53
|
+
console.error(`Failed to open the file explorer: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
31
57
|
}
|
|
32
58
|
exports.OsUtils = OsUtils;
|
|
33
59
|
//# sourceMappingURL=OsUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OsUtils.js","sourceRoot":"","sources":["../../src/utils/OsUtils.ts"],"names":[],"mappings":";;;AAAA,iDAAqC;AAErC,MAAa,OAAO;IAEhB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,GAAW;QAC5B,IAAI,OAAe,CAAC;QAEpB,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AkB;QACxC,IAAI,OAAe,CAAC;QAEpB,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;YACvB,KAAK,OAAO;gBACR,OAAO,GAAG,aAAa,UAAU,GAAG,CAAC;gBACrC,MAAM;YACV,KAAK,QAAQ;gBACT,OAAO,GAAG,SAAS,UAAU,GAAG,CAAC;gBACjC,MAAM;YACV;gBACI,oCAAoC;gBACpC,OAAO,GAAG,aAAa,UAAU,GAAG,CAAC;gBACrC,MAAM;QACd,CAAC;QAED,IAAA,oBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,gGAAgG;YAChG,IAAI,KAAK,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA1DD,0BA0DC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** Desktop OSes 'cn react package' can produce an installer for — always the one it runs on */
|
|
2
|
+
export type IPackageTarget = 'windows' | 'linux' | 'macos';
|
|
3
|
+
/**
|
|
4
|
+
* Desktop installers for the React apps, through Tauri: the static bundle of the app (see
|
|
5
|
+
* 'cn react build --static') is wrapped into a native window using the webview of the system,
|
|
6
|
+
* and bundled as an installer — NSIS .exe on Windows, .deb/.AppImage on Linux, .app/.dmg on
|
|
7
|
+
* macOS. Behind the command: cn react package <app>
|
|
8
|
+
*
|
|
9
|
+
* Installers do not cross-compile: each one is built on its own OS (a CI matrix covers the
|
|
10
|
+
* others). The machine needs the Rust toolchain — installed on demand through rustup when
|
|
11
|
+
* missing, see {@link PackageUtils.ensureCargo}; everything else (@tauri-apps/cli, the Tauri
|
|
12
|
+
* crates) is fetched into the staging by npm and cargo.
|
|
13
|
+
*/
|
|
14
|
+
export default abstract class PackageUtils {
|
|
15
|
+
/**
|
|
16
|
+
* Packages one React app of a Codenotch project as a desktop installer.
|
|
17
|
+
*
|
|
18
|
+
* The flow: check the target and the Rust toolchain (fail fast, the build is long), run the
|
|
19
|
+
* static build (environment baked in: a native window has no /api/env to fetch), then stage
|
|
20
|
+
* a generated Tauri project under `.codenotch/<appName>-package`:
|
|
21
|
+
* - package.json — only @tauri-apps/cli, installed on the first run
|
|
22
|
+
* - src-tauri/ — Cargo.toml, build.rs, src/main.rs (a bare webview window), tauri.conf.json
|
|
23
|
+
* pointing `frontendDist` at the `-dist` folder of the static build
|
|
24
|
+
* - src-tauri/icons/ — generated by 'tauri icon' from the biggest icon of the `pwa` section
|
|
25
|
+
* of the app manifest, or from a placeholder when there is none
|
|
26
|
+
*
|
|
27
|
+
* Unlike the build staging, this folder is NOT wiped between runs: cargo caches the compiled
|
|
28
|
+
* Tauri runtime under src-tauri/target, and only the first build pays the full compilation.
|
|
29
|
+
* 'cn react clean' deletes it like the other stagings.
|
|
30
|
+
*
|
|
31
|
+
* Returns the folder holding the installers on success, undefined otherwise (the reason is
|
|
32
|
+
* already printed).
|
|
33
|
+
*/
|
|
34
|
+
static packageReactApp(appFilePath: string, options?: {
|
|
35
|
+
target?: string;
|
|
36
|
+
clusterUrl?: string;
|
|
37
|
+
}): Promise<string | undefined>;
|
|
38
|
+
/** The OS this process runs on, as a packaging target */
|
|
39
|
+
static hostTarget(): IPackageTarget;
|
|
40
|
+
/**
|
|
41
|
+
* The target actually buildable here: the host OS. An explicit different target is refused
|
|
42
|
+
* with the CI suggestion — installers do not cross-compile.
|
|
43
|
+
*/
|
|
44
|
+
private static checkTarget;
|
|
45
|
+
private static hasCargo;
|
|
46
|
+
/**
|
|
47
|
+
* Checks the Rust toolchain, and proposes to install it through rustup when missing (in an
|
|
48
|
+
* interactive terminal only — elsewhere the manual instructions are printed instead). After
|
|
49
|
+
* a successful install, ~/.cargo/bin is adopted into the PATH of this process, so the
|
|
50
|
+
* packaging goes on without a new terminal.
|
|
51
|
+
*/
|
|
52
|
+
private static ensureCargo;
|
|
53
|
+
/** Prepends ~/.cargo/bin to the PATH of this process when cargo lives there; true when it does */
|
|
54
|
+
private static adoptCargoHome;
|
|
55
|
+
/**
|
|
56
|
+
* Downloads rustup-init.exe and runs it INTERACTIVELY: when the MSVC build tools are missing,
|
|
57
|
+
* rustup-init proposes their quick install — the silent '-y' mode would skip that and leave
|
|
58
|
+
* a toolchain unable to link.
|
|
59
|
+
*/
|
|
60
|
+
private static installRustWindows;
|
|
61
|
+
/** The documented one-liner, in its non-interactive form: stable toolchain, default profile */
|
|
62
|
+
private static installRustUnix;
|
|
63
|
+
private static printRustHelp;
|
|
64
|
+
/** The usual causes of a failed 'tauri build', per OS, printed after its own output */
|
|
65
|
+
private static printBuildHelp;
|
|
66
|
+
/** 'version' of the project manifest when it looks like x.y.z, or 0.1.0 (installers want numbers) */
|
|
67
|
+
private static projectVersion;
|
|
68
|
+
private static serviceName;
|
|
69
|
+
/** appName as a cargo crate name: lowercase, alphanumerics and underscores, no leading digit */
|
|
70
|
+
private static crateName;
|
|
71
|
+
/** A name as a segment of the bundle identifier: lowercase alphanumerics only */
|
|
72
|
+
private static identifierSegment;
|
|
73
|
+
private static createStagingPackageJson;
|
|
74
|
+
private static createCargoToml;
|
|
75
|
+
private static createBuildRs;
|
|
76
|
+
/** A bare Tauri app: one window on the static bundle, no API surface at all */
|
|
77
|
+
private static createMainRs;
|
|
78
|
+
private static createTauriConf;
|
|
79
|
+
/**
|
|
80
|
+
* The best source for the installer icons: the biggest icon of the `pwa` section of the app
|
|
81
|
+
* manifest, looked up next to the app manifest then from the workspace root, like the PWA
|
|
82
|
+
* build does. Undefined when the app declares none (or only URLs).
|
|
83
|
+
*/
|
|
84
|
+
private static findAppIcon;
|
|
85
|
+
/**
|
|
86
|
+
* Generates the full icon set (icon.ico, icon.icns, sized pngs) in src-tauri/icons with
|
|
87
|
+
* 'tauri icon'. Falls back to a generated placeholder when the app has no usable icon, or
|
|
88
|
+
* when the source is rejected (not square, no alpha channel...). Returns false only when
|
|
89
|
+
* even the placeholder fails, the reason printed by the tauri CLI itself.
|
|
90
|
+
*/
|
|
91
|
+
private static generateIcons;
|
|
92
|
+
/**
|
|
93
|
+
* A solid-color square PNG (RGBA), built by hand: enough for 'tauri icon', which wants a
|
|
94
|
+
* square image with an alpha channel, without pulling an image library into the CLI.
|
|
95
|
+
*/
|
|
96
|
+
private static createPlaceholderIcon;
|
|
97
|
+
private static pngChunk;
|
|
98
|
+
private static crc32;
|
|
99
|
+
/** The installer files tauri bundled, with their size — the raw binary is not one of them */
|
|
100
|
+
private static listInstallers;
|
|
101
|
+
}
|