@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.
Files changed (75) hide show
  1. package/dist/commands/generate/app.js +13 -2
  2. package/dist/commands/generate/app.js.map +1 -1
  3. package/dist/commands/generate/appmanifest.js +52 -3
  4. package/dist/commands/generate/appmanifest.js.map +1 -1
  5. package/dist/commands/generate/dbcontext.js +5 -1
  6. package/dist/commands/generate/dbcontext.js.map +1 -1
  7. package/dist/commands/generate/i18n.d.ts +1 -1
  8. package/dist/commands/generate/i18n.js +53 -10
  9. package/dist/commands/generate/i18n.js.map +1 -1
  10. package/dist/commands/generate/index.js +11 -2
  11. package/dist/commands/generate/index.js.map +1 -1
  12. package/dist/commands/generate/manifest.js +4 -0
  13. package/dist/commands/generate/manifest.js.map +1 -1
  14. package/dist/commands/generate/openapi.js +5 -1
  15. package/dist/commands/generate/openapi.js.map +1 -1
  16. package/dist/commands/generate/pkg.js +4 -0
  17. package/dist/commands/generate/pkg.js.map +1 -1
  18. package/dist/commands/generate/process.d.ts +2 -0
  19. package/dist/commands/generate/process.js +151 -0
  20. package/dist/commands/generate/process.js.map +1 -0
  21. package/dist/commands/project/index.js +8 -1
  22. package/dist/commands/project/index.js.map +1 -1
  23. package/dist/commands/project/new.js +16 -3
  24. package/dist/commands/project/new.js.map +1 -1
  25. package/dist/commands/project/remove.js +17 -1
  26. package/dist/commands/project/remove.js.map +1 -1
  27. package/dist/commands/react/build.js +22 -1
  28. package/dist/commands/react/build.js.map +1 -1
  29. package/dist/commands/react/clean.js +7 -2
  30. package/dist/commands/react/clean.js.map +1 -1
  31. package/dist/commands/react/dev.js +6 -0
  32. package/dist/commands/react/dev.js.map +1 -1
  33. package/dist/commands/react/index.js +11 -1
  34. package/dist/commands/react/index.js.map +1 -1
  35. package/dist/commands/react/package.d.ts +2 -0
  36. package/dist/commands/react/package.js +47 -0
  37. package/dist/commands/react/package.js.map +1 -0
  38. package/dist/commands/react/serve.js +5 -0
  39. package/dist/commands/react/serve.js.map +1 -1
  40. package/dist/commands/react/shared.js +1 -2
  41. package/dist/commands/react/shared.js.map +1 -1
  42. package/dist/commands/runtime/clear.js +15 -1
  43. package/dist/commands/runtime/clear.js.map +1 -1
  44. package/dist/commands/runtime/index.js +8 -1
  45. package/dist/commands/runtime/index.js.map +1 -1
  46. package/dist/commands/validation/ValidationUtils.js +1 -1
  47. package/dist/commands/validation/ValidationUtils.js.map +1 -1
  48. package/dist/commands/validation/files/I18nValidator.js +0 -9
  49. package/dist/commands/validation/files/I18nValidator.js.map +1 -1
  50. package/dist/commands/validation/files/ScriptValidator.js +6 -5
  51. package/dist/commands/validation/files/ScriptValidator.js.map +1 -1
  52. package/dist/commands/validation/validate.js +4 -13
  53. package/dist/commands/validation/validate.js.map +1 -1
  54. package/dist/utils/BuildUtils.d.ts +55 -5
  55. package/dist/utils/BuildUtils.js +238 -21
  56. package/dist/utils/BuildUtils.js.map +1 -1
  57. package/dist/utils/ConsoleUtils.d.ts +5 -2
  58. package/dist/utils/ConsoleUtils.js +20 -8
  59. package/dist/utils/ConsoleUtils.js.map +1 -1
  60. package/dist/utils/OsUtils.d.ts +6 -0
  61. package/dist/utils/OsUtils.js +26 -0
  62. package/dist/utils/OsUtils.js.map +1 -1
  63. package/dist/utils/PackageUtils.d.ts +101 -0
  64. package/dist/utils/PackageUtils.js +538 -0
  65. package/dist/utils/PackageUtils.js.map +1 -0
  66. package/dist/utils/ProcessModelUtils.d.ts +38 -0
  67. package/dist/utils/ProcessModelUtils.js +254 -0
  68. package/dist/utils/ProcessModelUtils.js.map +1 -0
  69. package/dist/utils/ProjectCompilationUtils.js.map +1 -1
  70. package/dist/utils/ServeUtils.js +1 -2
  71. package/dist/utils/ServeUtils.js.map +1 -1
  72. package/dist/utils/TemplateUtils.d.ts +1 -0
  73. package/dist/utils/TemplateUtils.js +21 -3
  74. package/dist/utils/TemplateUtils.js.map +1 -1
  75. package/package.json +1 -1
@@ -0,0 +1,538 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = require("fs");
7
+ const path_1 = require("path");
8
+ const os_1 = require("os");
9
+ const zlib_1 = require("zlib");
10
+ const fs_2 = __importDefault(require("fs"));
11
+ const chalk_1 = __importDefault(require("chalk"));
12
+ const StringUtils_1 = __importDefault(require("./StringUtils"));
13
+ const FileUtils_1 = __importDefault(require("./FileUtils"));
14
+ const ShellUtils_1 = __importDefault(require("./ShellUtils"));
15
+ const ConsoleUtils_1 = __importDefault(require("./ConsoleUtils"));
16
+ const BuildUtils_1 = __importDefault(require("./BuildUtils"));
17
+ /**
18
+ * Desktop installers for the React apps, through Tauri: the static bundle of the app (see
19
+ * 'cn react build --static') is wrapped into a native window using the webview of the system,
20
+ * and bundled as an installer — NSIS .exe on Windows, .deb/.AppImage on Linux, .app/.dmg on
21
+ * macOS. Behind the command: cn react package <app>
22
+ *
23
+ * Installers do not cross-compile: each one is built on its own OS (a CI matrix covers the
24
+ * others). The machine needs the Rust toolchain — installed on demand through rustup when
25
+ * missing, see {@link PackageUtils.ensureCargo}; everything else (@tauri-apps/cli, the Tauri
26
+ * crates) is fetched into the staging by npm and cargo.
27
+ */
28
+ class PackageUtils {
29
+ /**
30
+ * Packages one React app of a Codenotch project as a desktop installer.
31
+ *
32
+ * The flow: check the target and the Rust toolchain (fail fast, the build is long), run the
33
+ * static build (environment baked in: a native window has no /api/env to fetch), then stage
34
+ * a generated Tauri project under `.codenotch/<appName>-package`:
35
+ * - package.json — only @tauri-apps/cli, installed on the first run
36
+ * - src-tauri/ — Cargo.toml, build.rs, src/main.rs (a bare webview window), tauri.conf.json
37
+ * pointing `frontendDist` at the `-dist` folder of the static build
38
+ * - src-tauri/icons/ — generated by 'tauri icon' from the biggest icon of the `pwa` section
39
+ * of the app manifest, or from a placeholder when there is none
40
+ *
41
+ * Unlike the build staging, this folder is NOT wiped between runs: cargo caches the compiled
42
+ * Tauri runtime under src-tauri/target, and only the first build pays the full compilation.
43
+ * 'cn react clean' deletes it like the other stagings.
44
+ *
45
+ * Returns the folder holding the installers on success, undefined otherwise (the reason is
46
+ * already printed).
47
+ */
48
+ static async packageReactApp(appFilePath, options = {}) {
49
+ // resolve() already turns a relative path into an absolute one, based on the current directory
50
+ appFilePath = StringUtils_1.default.normalizePath((0, path_1.resolve)(appFilePath));
51
+ if ((0, fs_1.existsSync)(appFilePath) === false) {
52
+ console.log(chalk_1.default.red(`Error: File "${appFilePath}" not found`));
53
+ return undefined;
54
+ }
55
+ let workspacePath = BuildUtils_1.default.findWorkspaceFromFile(appFilePath) ?? '';
56
+ if (workspacePath === '' || (0, fs_1.existsSync)(workspacePath) === false) {
57
+ console.log(chalk_1.default.red(`Error: Could not find workspace manifest for file "${appFilePath}".`));
58
+ return undefined;
59
+ }
60
+ // App manifest, named like the component
61
+ let appFilename = StringUtils_1.default.getFilenameFromUri(appFilePath);
62
+ let appFolderPath = StringUtils_1.default.getFolder(appFilePath);
63
+ let appManifestPath = StringUtils_1.default.normalizePath(`${appFolderPath}/${appFilename.replace(/\.[^/.]+$/, '.manifest.json')}`);
64
+ if ((0, fs_1.existsSync)(appManifestPath) === false) {
65
+ console.log(chalk_1.default.red(`Error: App manifest file not found at "${appManifestPath}"`));
66
+ return undefined;
67
+ }
68
+ let appManifest = JSON.parse(fs_2.default.readFileSync(appManifestPath, 'utf-8'));
69
+ let appName = `${appManifest.app?.name ?? ''}`.trim();
70
+ if (appName === '') {
71
+ console.log(chalk_1.default.red(`Error: App name not found in manifest at "${appManifestPath}"`));
72
+ return undefined;
73
+ }
74
+ // Only the OS the command runs on: installers do not cross-compile
75
+ const target = this.checkTarget(options.target);
76
+ if (target === undefined) {
77
+ return undefined;
78
+ }
79
+ // Rust next: a missing toolchain should fail (or be installed) before the (long) static build
80
+ if (await this.ensureCargo(target) === false) {
81
+ return undefined;
82
+ }
83
+ // The installer wraps a bundle that must run without a Codenotch host behind it
84
+ console.log(chalk_1.default.green(`Packaging "${appName}" for ${target}...\n`));
85
+ const distPath = await BuildUtils_1.default.buildReactApp(appFilePath, { clusterUrl: options.clusterUrl, static: true });
86
+ if (distPath === undefined) {
87
+ return undefined;
88
+ }
89
+ // The staging is kept between runs: src-tauri/target holds the cargo cache, and only
90
+ // the first build compiles the Tauri runtime. 'cn react clean' deletes it.
91
+ let stagingPath = StringUtils_1.default.normalizePath(`${workspacePath}/.codenotch/${appName}-package`);
92
+ let version = this.projectVersion(workspacePath);
93
+ let serviceName = this.serviceName(workspacePath);
94
+ console.log('');
95
+ console.log("Creating packaging files...");
96
+ FileUtils_1.default.writeFileSync(stagingPath + '/package.json', JSON.stringify(this.createStagingPackageJson(appName), null, 4));
97
+ FileUtils_1.default.writeFileSync(stagingPath + '/src-tauri/Cargo.toml', this.createCargoToml(appName, version));
98
+ FileUtils_1.default.writeFileSync(stagingPath + '/src-tauri/build.rs', this.createBuildRs());
99
+ FileUtils_1.default.writeFileSync(stagingPath + '/src-tauri/src/main.rs', this.createMainRs());
100
+ ConsoleUtils_1.default.check(`Tauri project files created in ${stagingPath}\n`);
101
+ // Dependencies first: 'tauri icon' below needs the local @tauri-apps/cli
102
+ if ((0, fs_1.existsSync)(StringUtils_1.default.normalizePath(`${stagingPath}/node_modules`)) === false) {
103
+ console.log("Installing packaging dependencies...");
104
+ const installCode = await ShellUtils_1.default.run(stagingPath, 'npm install --no-audit --no-fund');
105
+ if (installCode !== 0) {
106
+ console.log(chalk_1.default.red(`Error: npm install failed (exit code ${installCode}).`));
107
+ return undefined;
108
+ }
109
+ }
110
+ // Icons are generated once; delete the staging (or the icons folder) to refresh them
111
+ if ((0, fs_1.existsSync)(StringUtils_1.default.normalizePath(`${stagingPath}/src-tauri/icons/icon.ico`)) === false) {
112
+ const generated = await this.generateIcons(stagingPath, this.findAppIcon(appManifest, appFolderPath, workspacePath));
113
+ if (generated === false) {
114
+ return undefined;
115
+ }
116
+ }
117
+ // The conf lists the icon files actually generated, so it comes after them
118
+ FileUtils_1.default.writeFileSync(stagingPath + '/src-tauri/tauri.conf.json', JSON.stringify(this.createTauriConf(appManifest, appName, serviceName, version, target, stagingPath), null, 4));
119
+ ConsoleUtils_1.default.check(`tauri.conf.json created successfully\n`);
120
+ console.log(chalk_1.default.green(`Building the ${target} installer (the first run compiles the Tauri runtime, expect several minutes)...\n`));
121
+ const buildCode = await ShellUtils_1.default.run(stagingPath, 'npx --no-install tauri build');
122
+ if (buildCode !== 0) {
123
+ console.log(chalk_1.default.red(`\nError: 'tauri build' failed (exit code ${buildCode}).`));
124
+ this.printBuildHelp(target);
125
+ return undefined;
126
+ }
127
+ const bundleDir = StringUtils_1.default.normalizePath(`${stagingPath}/src-tauri/target/release/bundle`);
128
+ const installers = this.listInstallers(bundleDir);
129
+ console.log('');
130
+ console.log(chalk_1.default.green(`Packaging completed!\n`));
131
+ if (installers.length === 0) {
132
+ console.log(chalk_1.default.yellow(`No installer found under "${bundleDir}" — check the build output above.`));
133
+ return undefined;
134
+ }
135
+ console.log(`Installer(s) available:\n`);
136
+ for (const installer of installers) {
137
+ console.log(chalk_1.default.green(` ${installer.path}`) + ` (${installer.sizeMb} MB)`);
138
+ }
139
+ console.log('');
140
+ console.log(`The installers are not signed: Windows SmartScreen / macOS Gatekeeper will warn on first launch.`);
141
+ return bundleDir;
142
+ }
143
+ /** The OS this process runs on, as a packaging target */
144
+ static hostTarget() {
145
+ return process.platform === 'win32' ? 'windows' :
146
+ process.platform === 'darwin' ? 'macos' :
147
+ 'linux';
148
+ }
149
+ /**
150
+ * The target actually buildable here: the host OS. An explicit different target is refused
151
+ * with the CI suggestion — installers do not cross-compile.
152
+ */
153
+ static checkTarget(requested) {
154
+ const host = this.hostTarget();
155
+ if (requested === undefined) {
156
+ return host;
157
+ }
158
+ const wanted = requested.toLowerCase();
159
+ if (wanted !== 'windows' && wanted !== 'linux' && wanted !== 'macos') {
160
+ console.log(chalk_1.default.red(`Error: Unknown target "${requested}". Possible targets: windows, linux, macos.`));
161
+ return undefined;
162
+ }
163
+ if (wanted !== host) {
164
+ console.log(chalk_1.default.red(`Error: A ${wanted} installer can only be built on ${wanted} (installers do not cross-compile).`));
165
+ console.log(`This ${host} machine can build the ${host} installer; use a CI matrix (e.g. GitHub Actions with windows/macos/ubuntu runners) for the others.`);
166
+ return undefined;
167
+ }
168
+ return wanted;
169
+ }
170
+ static async hasCargo() {
171
+ try {
172
+ await ShellUtils_1.default.exec(process.cwd(), 'cargo --version', undefined, true);
173
+ return true;
174
+ }
175
+ catch {
176
+ return false;
177
+ }
178
+ }
179
+ /**
180
+ * Checks the Rust toolchain, and proposes to install it through rustup when missing (in an
181
+ * interactive terminal only — elsewhere the manual instructions are printed instead). After
182
+ * a successful install, ~/.cargo/bin is adopted into the PATH of this process, so the
183
+ * packaging goes on without a new terminal.
184
+ */
185
+ static async ensureCargo(target) {
186
+ if (await this.hasCargo()) {
187
+ return true;
188
+ }
189
+ // An existing install may just be missing from the PATH of this terminal
190
+ if (this.adoptCargoHome()) {
191
+ ConsoleUtils_1.default.check(`Rust toolchain found in ~/.cargo/bin (it was not on the PATH of this terminal).\n`);
192
+ return true;
193
+ }
194
+ console.log(chalk_1.default.yellow(`The Rust toolchain (cargo) is needed to build the installer, and was not found.`));
195
+ if (process.stdin.isTTY !== true) {
196
+ this.printRustHelp(target);
197
+ return false;
198
+ }
199
+ if (await ConsoleUtils_1.default.confirm(`Install it now with rustup (https://rustup.rs)?`, true) === false) {
200
+ this.printRustHelp(target);
201
+ return false;
202
+ }
203
+ const installed = target === 'windows' ?
204
+ await this.installRustWindows() :
205
+ await this.installRustUnix(target);
206
+ if (installed === false) {
207
+ this.printRustHelp(target);
208
+ return false;
209
+ }
210
+ // rustup updates the persistent environment, not this process: adopt ~/.cargo/bin now
211
+ this.adoptCargoHome();
212
+ if (await this.hasCargo() === false) {
213
+ console.log(chalk_1.default.yellow(`rustup finished, but 'cargo' is still not callable from this process: open a new terminal and run the command again.`));
214
+ return false;
215
+ }
216
+ ConsoleUtils_1.default.check(`Rust toolchain installed successfully.\n`);
217
+ return true;
218
+ }
219
+ /** Prepends ~/.cargo/bin to the PATH of this process when cargo lives there; true when it does */
220
+ static adoptCargoHome() {
221
+ const cargoBin = StringUtils_1.default.normalizePath(`${(0, os_1.homedir)()}/.cargo/bin`);
222
+ const cargoExe = StringUtils_1.default.normalizePath(`${cargoBin}/cargo${process.platform === 'win32' ? '.exe' : ''}`);
223
+ if ((0, fs_1.existsSync)(cargoExe) === false) {
224
+ return false;
225
+ }
226
+ if ((process.env.PATH ?? '').includes(cargoBin) === false) {
227
+ process.env.PATH = `${cargoBin}${path_1.delimiter}${process.env.PATH ?? ''}`;
228
+ }
229
+ return true;
230
+ }
231
+ /**
232
+ * Downloads rustup-init.exe and runs it INTERACTIVELY: when the MSVC build tools are missing,
233
+ * rustup-init proposes their quick install — the silent '-y' mode would skip that and leave
234
+ * a toolchain unable to link.
235
+ */
236
+ static async installRustWindows() {
237
+ const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
238
+ const installerPath = StringUtils_1.default.normalizePath(`${(0, os_1.tmpdir)()}/rustup-init.exe`);
239
+ try {
240
+ console.log(`Downloading rustup-init.exe (${arch})...`);
241
+ const response = await fetch(`https://win.rustup.rs/${arch}`);
242
+ if (response.ok === false) {
243
+ throw new Error(`HTTP ${response.status}`);
244
+ }
245
+ fs_2.default.writeFileSync(installerPath, Buffer.from(await response.arrayBuffer()));
246
+ }
247
+ catch (error) {
248
+ console.log(chalk_1.default.red(`Error: could not download rustup-init.exe (${error?.message ?? error}).`));
249
+ return false;
250
+ }
251
+ console.log(`Running the rustup installer — accept the defaults when unsure; it can also install the missing Visual Studio C++ build tools...\n`);
252
+ const code = await ShellUtils_1.default.run(process.cwd(), `"${installerPath}"`);
253
+ return code === 0;
254
+ }
255
+ /** The documented one-liner, in its non-interactive form: stable toolchain, default profile */
256
+ static async installRustUnix(target) {
257
+ console.log(`Installing rustup (stable toolchain)...\n`);
258
+ const code = await ShellUtils_1.default.run(process.cwd(), `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y`);
259
+ if (code !== 0) {
260
+ console.log(chalk_1.default.red(`Error: the rustup install failed (exit code ${code}).`));
261
+ return false;
262
+ }
263
+ if (target === 'linux') {
264
+ console.log(`Reminder: the webview dev packages are needed too, e.g. on Debian/Ubuntu:`);
265
+ console.log(chalk_1.default.green(`sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev`));
266
+ }
267
+ else {
268
+ console.log(`Reminder: the Xcode command line tools are needed too when not already present: ${chalk_1.default.green('xcode-select --install')}`);
269
+ }
270
+ return true;
271
+ }
272
+ static printRustHelp(target) {
273
+ console.log(chalk_1.default.red(`Error: Rust toolchain not found ('cargo' is not on the PATH), and Tauri needs it to build the installer.`));
274
+ console.log(`Install it from ${chalk_1.default.green('https://rustup.rs')} then run the command again (in a fresh terminal).`);
275
+ if (target === 'windows') {
276
+ console.log(`On Windows, pick the MSVC toolchain: rustup proposes to install the Visual Studio 'Desktop development with C++' build tools when they are missing.`);
277
+ }
278
+ else if (target === 'linux') {
279
+ console.log(`On Linux, the webview dev packages are needed too, e.g. on Debian/Ubuntu:`);
280
+ console.log(chalk_1.default.green(`sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev`));
281
+ }
282
+ else {
283
+ console.log(`On macOS, the Xcode command line tools are needed too: ${chalk_1.default.green('xcode-select --install')}`);
284
+ }
285
+ }
286
+ /** The usual causes of a failed 'tauri build', per OS, printed after its own output */
287
+ static printBuildHelp(target) {
288
+ if (target === 'windows') {
289
+ console.log(`If the error mentions 'link.exe' or a missing linker, install the Visual Studio 'Desktop development with C++' build tools and retry.`);
290
+ }
291
+ else if (target === 'linux') {
292
+ console.log(`If the error mentions webkit2gtk, soup or javascriptcore, install the Tauri prerequisites, e.g. on Debian/Ubuntu:`);
293
+ console.log(chalk_1.default.green(`sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev`));
294
+ }
295
+ else {
296
+ console.log(`If the error mentions xcrun or missing developer tools: ${chalk_1.default.green('xcode-select --install')}`);
297
+ }
298
+ }
299
+ /** 'version' of the project manifest when it looks like x.y.z, or 0.1.0 (installers want numbers) */
300
+ static projectVersion(workspacePath) {
301
+ try {
302
+ const manifest = BuildUtils_1.default.getFullManifestAt(workspacePath);
303
+ const match = `${manifest?.version ?? ''}`.match(/^\d+\.\d+\.\d+/);
304
+ if (match !== null) {
305
+ return match[0];
306
+ }
307
+ }
308
+ catch { }
309
+ return '0.1.0';
310
+ }
311
+ static serviceName(workspacePath) {
312
+ try {
313
+ return `${BuildUtils_1.default.getFullManifestAt(workspacePath).serviceName ?? ''}`.trim();
314
+ }
315
+ catch {
316
+ return '';
317
+ }
318
+ }
319
+ /** appName as a cargo crate name: lowercase, alphanumerics and underscores, no leading digit */
320
+ static crateName(appName) {
321
+ let name = appName.toLowerCase().replace(/[^a-z0-9_]/g, '_');
322
+ if (name === '' || /^[0-9]/.test(name)) {
323
+ name = `app_${name}`;
324
+ }
325
+ return name;
326
+ }
327
+ /** A name as a segment of the bundle identifier: lowercase alphanumerics only */
328
+ static identifierSegment(name) {
329
+ let segment = name.toLowerCase().replace(/[^a-z0-9]/g, '');
330
+ return segment === '' ? 'app' : segment;
331
+ }
332
+ static createStagingPackageJson(appName) {
333
+ return {
334
+ "name": `${this.crateName(appName)}-package`,
335
+ "private": true,
336
+ "version": "1.0.0",
337
+ "scripts": {
338
+ "tauri": "tauri"
339
+ },
340
+ "devDependencies": {
341
+ "@tauri-apps/cli": "^2.0.0"
342
+ }
343
+ };
344
+ }
345
+ static createCargoToml(appName, version) {
346
+ return `
347
+ [package]
348
+ name = ${JSON.stringify(this.crateName(appName))}
349
+ version = ${JSON.stringify(version)}
350
+ description = ${JSON.stringify(`${appName} — Codenotch app packaged by 'cn react package'`)}
351
+ edition = "2021"
352
+
353
+ [build-dependencies]
354
+ tauri-build = { version = "2", features = [] }
355
+
356
+ [dependencies]
357
+ tauri = { version = "2", features = [] }
358
+
359
+ [profile.release]
360
+ strip = true
361
+ `.trim();
362
+ }
363
+ static createBuildRs() {
364
+ return `
365
+ fn main() {
366
+ tauri_build::build()
367
+ }
368
+ `.trim();
369
+ }
370
+ /** A bare Tauri app: one window on the static bundle, no API surface at all */
371
+ static createMainRs() {
372
+ return `
373
+ // Prevents an extra console window on Windows in release builds
374
+ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
375
+
376
+ fn main() {
377
+ tauri::Builder::default()
378
+ .run(tauri::generate_context!())
379
+ .expect("error while running tauri application");
380
+ }
381
+ `.trim();
382
+ }
383
+ static createTauriConf(appManifest, appName, serviceName, version, target, stagingPath) {
384
+ // Only the icon files 'tauri icon' actually generated: a missing listed file fails the bundle
385
+ let iconsDir = StringUtils_1.default.normalizePath(`${stagingPath}/src-tauri/icons`);
386
+ let iconFiles = [];
387
+ if ((0, fs_1.existsSync)(iconsDir)) {
388
+ iconFiles = fs_2.default.readdirSync(iconsDir)
389
+ .filter(f => f === 'icon.ico' || f === 'icon.icns' || /^\d+x\d+(@2x)?\.png$/.test(f))
390
+ .map(f => `icons/${f}`);
391
+ }
392
+ let targets = target === 'windows' ? ['nsis'] :
393
+ target === 'macos' ? ['app', 'dmg'] :
394
+ ['deb', 'appimage'];
395
+ let identifier = serviceName === '' ?
396
+ `com.codenotch.${this.identifierSegment(appName)}` :
397
+ `com.codenotch.${this.identifierSegment(serviceName)}.${this.identifierSegment(appName)}`;
398
+ return {
399
+ "$schema": "https://schema.tauri.app/config/2",
400
+ "productName": appName,
401
+ "version": version,
402
+ "identifier": identifier,
403
+ "build": {
404
+ // Already produced by the static build: tauri only wraps the dist, no dev server
405
+ "frontendDist": `../../${appName}-dist`
406
+ },
407
+ "app": {
408
+ "windows": [
409
+ {
410
+ "title": appManifest.html?.title ?? appName,
411
+ "width": 1280,
412
+ "height": 800
413
+ }
414
+ ],
415
+ "security": {
416
+ "csp": null
417
+ }
418
+ },
419
+ "bundle": {
420
+ "active": true,
421
+ "targets": targets,
422
+ "icon": iconFiles
423
+ }
424
+ };
425
+ }
426
+ /**
427
+ * The best source for the installer icons: the biggest icon of the `pwa` section of the app
428
+ * manifest, looked up next to the app manifest then from the workspace root, like the PWA
429
+ * build does. Undefined when the app declares none (or only URLs).
430
+ */
431
+ static findAppIcon(appManifest, appFolderPath, workspacePath) {
432
+ // Biggest first: 'tauri icon' downscales cleanly, upscaling a small one would blur
433
+ let icons = [...(appManifest.pwa?.icons ?? [])]
434
+ .sort((a, b) => (parseInt(`${b.sizes ?? ''}`) || 0) - (parseInt(`${a.sizes ?? ''}`) || 0));
435
+ for (let icon of icons) {
436
+ let src = `${icon.src ?? ''}`.trim();
437
+ if (src === '' || /^(https?:|data:)/i.test(src)) {
438
+ continue;
439
+ }
440
+ let candidates = [
441
+ StringUtils_1.default.normalizePath(`${appFolderPath}/${src}`),
442
+ StringUtils_1.default.normalizePath(`${workspacePath}/${src}`)
443
+ ];
444
+ let found = candidates.find(c => (0, fs_1.existsSync)(c));
445
+ if (found !== undefined) {
446
+ return found;
447
+ }
448
+ }
449
+ return undefined;
450
+ }
451
+ /**
452
+ * Generates the full icon set (icon.ico, icon.icns, sized pngs) in src-tauri/icons with
453
+ * 'tauri icon'. Falls back to a generated placeholder when the app has no usable icon, or
454
+ * when the source is rejected (not square, no alpha channel...). Returns false only when
455
+ * even the placeholder fails, the reason printed by the tauri CLI itself.
456
+ */
457
+ static async generateIcons(stagingPath, sourceIconPath) {
458
+ if (sourceIconPath === undefined) {
459
+ ConsoleUtils_1.default.checkWarning(`No usable icon in the pwa section of the app manifest: using a placeholder (a square PNG with transparency, 512px or more, is recommended).`);
460
+ }
461
+ else {
462
+ console.log(`Generating installer icons from "${sourceIconPath}"...`);
463
+ const code = await ShellUtils_1.default.run(stagingPath, `npx --no-install tauri icon "${sourceIconPath}" -o src-tauri/icons`);
464
+ if (code === 0) {
465
+ ConsoleUtils_1.default.check(`Installer icons generated successfully\n`);
466
+ return true;
467
+ }
468
+ ConsoleUtils_1.default.checkWarning(`'tauri icon' rejected "${sourceIconPath}" (it wants a square PNG with an alpha channel): using a placeholder instead.`);
469
+ }
470
+ const placeholderPath = StringUtils_1.default.normalizePath(`${stagingPath}/app-icon.png`);
471
+ fs_2.default.writeFileSync(placeholderPath, this.createPlaceholderIcon(1024, [30, 41, 59, 255]));
472
+ const code = await ShellUtils_1.default.run(stagingPath, `npx --no-install tauri icon "${placeholderPath}" -o src-tauri/icons`);
473
+ if (code !== 0) {
474
+ console.log(chalk_1.default.red(`Error: could not generate the installer icons ('tauri icon' failed, see its output above).`));
475
+ return false;
476
+ }
477
+ ConsoleUtils_1.default.check(`Installer icons generated successfully\n`);
478
+ return true;
479
+ }
480
+ /**
481
+ * A solid-color square PNG (RGBA), built by hand: enough for 'tauri icon', which wants a
482
+ * square image with an alpha channel, without pulling an image library into the CLI.
483
+ */
484
+ static createPlaceholderIcon(size, rgba) {
485
+ // One scanline: a filter byte (0, none) then the RGBA pixels
486
+ let row = Buffer.alloc(1 + size * 4);
487
+ for (let x = 0; x < size; x++) {
488
+ row[1 + x * 4] = rgba[0];
489
+ row[2 + x * 4] = rgba[1];
490
+ row[3 + x * 4] = rgba[2];
491
+ row[4 + x * 4] = rgba[3];
492
+ }
493
+ let raw = Buffer.concat(new Array(size).fill(row));
494
+ let ihdr = Buffer.alloc(13);
495
+ ihdr.writeUInt32BE(size, 0); // width
496
+ ihdr.writeUInt32BE(size, 4); // height
497
+ ihdr[8] = 8; // bit depth
498
+ ihdr[9] = 6; // color type: truecolor with alpha
499
+ return Buffer.concat([
500
+ Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]), // PNG signature
501
+ this.pngChunk('IHDR', ihdr),
502
+ this.pngChunk('IDAT', (0, zlib_1.deflateSync)(raw)),
503
+ this.pngChunk('IEND', Buffer.alloc(0))
504
+ ]);
505
+ }
506
+ static pngChunk(type, data) {
507
+ let payload = Buffer.concat([Buffer.from(type, 'ascii'), data]);
508
+ let header = Buffer.alloc(4);
509
+ header.writeUInt32BE(data.length, 0);
510
+ let crc = Buffer.alloc(4);
511
+ crc.writeUInt32BE(this.crc32(payload), 0);
512
+ return Buffer.concat([header, payload, crc]);
513
+ }
514
+ static crc32(data) {
515
+ let crc = 0xFFFFFFFF;
516
+ for (let i = 0; i < data.length; i++) {
517
+ crc ^= data[i];
518
+ for (let bit = 0; bit < 8; bit++) {
519
+ crc = (crc >>> 1) ^ (0xEDB88320 & -(crc & 1));
520
+ }
521
+ }
522
+ return (crc ^ 0xFFFFFFFF) >>> 0;
523
+ }
524
+ /** The installer files tauri bundled, with their size — the raw binary is not one of them */
525
+ static listInstallers(bundleDir) {
526
+ if ((0, fs_1.existsSync)(bundleDir) === false) {
527
+ return [];
528
+ }
529
+ return FileUtils_1.default.listFilesRecursively(bundleDir, {
530
+ fileExtensions: ['.exe', '.msi', '.dmg', '.deb', '.rpm', '.AppImage']
531
+ }).map(f => ({
532
+ path: StringUtils_1.default.normalizePath(f),
533
+ sizeMb: (fs_2.default.statSync(f).size / (1024 * 1024)).toFixed(1)
534
+ }));
535
+ }
536
+ }
537
+ exports.default = PackageUtils;
538
+ //# sourceMappingURL=PackageUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageUtils.js","sourceRoot":"","sources":["../../src/utils/PackageUtils.ts"],"names":[],"mappings":";;;;;AAAA,2BAAgC;AAChC,+BAA0C;AAC1C,2BAAqC;AACrC,+BAAmC;AACnC,4CAAoB;AACpB,kDAA0B;AAC1B,gEAAwC;AACxC,4DAAoC;AACpC,8DAAsC;AACtC,kEAA0C;AAC1C,8DAAsC;AAMtC;;;;;;;;;;GAUG;AACH,MAA8B,YAAY;IAEtC;;;;;;;;;;;;;;;;;;OAkBG;I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AC,CAAC;YACf,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;gBAC/B,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC;QACL,CAAC;QACD,OAAO,CAAC,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,6FAA6F;IACrF,MAAM,CAAC,cAAc,CAAC,SAAiB;QAC3C,IAAI,IAAA,eAAU,EAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,EAAE,CAAC;QACd,CAAC;QACD,OAAO,mBAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE;YAC7C,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC;SACxE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACT,IAAI,EAAE,qBAAW,CAAC,aAAa,CAAC,CAAC,CAAC;YAClC,MAAM,EAAE,CAAC,YAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;SAC3D,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AApjBD,+BAojBC"}
@@ -0,0 +1,38 @@
1
+ import { IDiscoveredTable } from './ProjectUtils';
2
+ /** A boilerplate process 'cn generate process' can write for a table */
3
+ export type ProcessModelName = 'api' | 'insert' | 'insert-full' | 'update' | 'upsert' | 'delete' | 'clean';
4
+ export declare const PROCESS_MODELS: {
5
+ name: ProcessModelName;
6
+ description: string;
7
+ }[];
8
+ export interface IProcessModelResult {
9
+ /** Undefined when nothing can be generated, see error */
10
+ content?: string;
11
+ warnings: string[];
12
+ error?: string;
13
+ }
14
+ /**
15
+ * Builds ready-to-edit boilerplate processes for a table discovered in the project, in the exact
16
+ * style of the 'cn project new' templates. Everything is derived from the sources (row type
17
+ * import, primary key, required fields); where the runtime API is not settled yet, the generated
18
+ * code carries a TODO instead of a guess presented as certain.
19
+ */
20
+ export default abstract class ProcessModelUtils {
21
+ /** Name of the process file, e.g. 'delete-todo-list.ts' or 'book-api.ts' for the api bundle */
22
+ static getFileName(model: ProcessModelName, table: IDiscoveredTable): string;
23
+ /** Name of the query file the list endpoint of the 'api' model reads, e.g. 'all-books.cnql' */
24
+ static getQueryFileName(table: IDiscoveredTable): string;
25
+ /**
26
+ * Content of the process file for the given model.
27
+ * @param targetFilePath where the file will be written, to compute the import of the row type
28
+ */
29
+ static createProcessFile(model: ProcessModelName, table: IDiscoveredTable, targetFilePath: string): IProcessModelResult;
30
+ /** Content of the 'all rows' cnql query the list endpoint of the 'api' model reads */
31
+ static createAllRowsQuery(table: IDiscoveredTable, serviceName: string): string;
32
+ private static renderBlock;
33
+ /** Module specifier importing the table file from the generated one: posix, no extension */
34
+ private static toSpecifier;
35
+ /** 'TodoList' gives 'todo-list' */
36
+ private static toKebab;
37
+ private static capitalize;
38
+ }