@codenotch/codenotch.cli 1.0.40 → 1.0.42

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 (104) hide show
  1. package/README.md +78 -28
  2. package/dist/commands/generate/app.js +6 -0
  3. package/dist/commands/generate/app.js.map +1 -1
  4. package/dist/commands/generate/appmanifest.js +5 -0
  5. package/dist/commands/generate/appmanifest.js.map +1 -1
  6. package/dist/commands/generate/dbcontext.js +6 -2
  7. package/dist/commands/generate/dbcontext.js.map +1 -1
  8. package/dist/commands/generate/i18n.js +5 -0
  9. package/dist/commands/generate/i18n.js.map +1 -1
  10. package/dist/commands/generate/index.js +8 -1
  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.js +6 -0
  19. package/dist/commands/generate/process.js.map +1 -1
  20. package/dist/commands/project/deploy.js +9 -2
  21. package/dist/commands/project/deploy.js.map +1 -1
  22. package/dist/commands/project/index.js +8 -1
  23. package/dist/commands/project/index.js.map +1 -1
  24. package/dist/commands/project/inspect.js +65 -1
  25. package/dist/commands/project/inspect.js.map +1 -1
  26. package/dist/commands/project/new.js +7 -1
  27. package/dist/commands/project/new.js.map +1 -1
  28. package/dist/commands/project/remove.js +6 -1
  29. package/dist/commands/project/remove.js.map +1 -1
  30. package/dist/commands/react/build.js +22 -1
  31. package/dist/commands/react/build.js.map +1 -1
  32. package/dist/commands/react/clean.js +7 -2
  33. package/dist/commands/react/clean.js.map +1 -1
  34. package/dist/commands/react/dev.js +6 -0
  35. package/dist/commands/react/dev.js.map +1 -1
  36. package/dist/commands/react/index.js +11 -1
  37. package/dist/commands/react/index.js.map +1 -1
  38. package/dist/commands/react/package.d.ts +2 -0
  39. package/dist/commands/react/package.js +47 -0
  40. package/dist/commands/react/package.js.map +1 -0
  41. package/dist/commands/react/serve.js +5 -0
  42. package/dist/commands/react/serve.js.map +1 -1
  43. package/dist/commands/runtime/clear.js +5 -0
  44. package/dist/commands/runtime/clear.js.map +1 -1
  45. package/dist/commands/runtime/index.js +8 -1
  46. package/dist/commands/runtime/index.js.map +1 -1
  47. package/dist/commands/system/docs.d.ts +2 -0
  48. package/dist/commands/system/docs.js +57 -0
  49. package/dist/commands/system/docs.js.map +1 -0
  50. package/dist/commands/system/index.js +2 -0
  51. package/dist/commands/system/index.js.map +1 -1
  52. package/dist/commands/system/read.js +2 -1
  53. package/dist/commands/system/read.js.map +1 -1
  54. package/dist/commands/validation/files/ScriptValidator.js +9 -8
  55. package/dist/commands/validation/files/ScriptValidator.js.map +1 -1
  56. package/dist/commands/validation/validate.js +4 -13
  57. package/dist/commands/validation/validate.js.map +1 -1
  58. package/dist/index.js +12 -2
  59. package/dist/index.js.map +1 -1
  60. package/dist/utils/BuildUtils.d.ts +53 -5
  61. package/dist/utils/BuildUtils.js +233 -21
  62. package/dist/utils/BuildUtils.js.map +1 -1
  63. package/dist/utils/ConsoleUtils.d.ts +0 -2
  64. package/dist/utils/ConsoleUtils.js +0 -8
  65. package/dist/utils/ConsoleUtils.js.map +1 -1
  66. package/dist/utils/DbSchemaUtils.d.ts +16 -10
  67. package/dist/utils/DbSchemaUtils.js +82 -30
  68. package/dist/utils/DbSchemaUtils.js.map +1 -1
  69. package/dist/utils/DocsUtils.d.ts +34 -0
  70. package/dist/utils/DocsUtils.js +76 -0
  71. package/dist/utils/DocsUtils.js.map +1 -0
  72. package/dist/utils/OsUtils.d.ts +6 -0
  73. package/dist/utils/OsUtils.js +26 -0
  74. package/dist/utils/OsUtils.js.map +1 -1
  75. package/dist/utils/PackageUtils.d.ts +101 -0
  76. package/dist/utils/PackageUtils.js +538 -0
  77. package/dist/utils/PackageUtils.js.map +1 -0
  78. package/dist/utils/ProcessBundlerUtils.d.ts +103 -0
  79. package/dist/utils/ProcessBundlerUtils.js +336 -0
  80. package/dist/utils/ProcessBundlerUtils.js.map +1 -0
  81. package/dist/utils/ProjectCompilationUtils.d.ts +14 -2
  82. package/dist/utils/ProjectCompilationUtils.js +75 -3
  83. package/dist/utils/ProjectCompilationUtils.js.map +1 -1
  84. package/dist/utils/ProjectGeneratorUtils.d.ts +2 -1
  85. package/dist/utils/ProjectGeneratorUtils.js +21 -14
  86. package/dist/utils/ProjectGeneratorUtils.js.map +1 -1
  87. package/dist/utils/ProjectTemplates.d.ts +2 -2
  88. package/dist/utils/ProjectTemplates.js +12 -6
  89. package/dist/utils/ProjectTemplates.js.map +1 -1
  90. package/dist/utils/ProjectUtils.d.ts +18 -1
  91. package/dist/utils/ProjectUtils.js +33 -28
  92. package/dist/utils/ProjectUtils.js.map +1 -1
  93. package/dist/utils/ServeUtils.js +1 -2
  94. package/dist/utils/ServeUtils.js.map +1 -1
  95. package/dist/utils/TemplateUtils.d.ts +29 -0
  96. package/dist/utils/TemplateUtils.js +96 -3
  97. package/dist/utils/TemplateUtils.js.map +1 -1
  98. package/package.json +78 -71
  99. package/resources/docs/apps.md +109 -0
  100. package/resources/docs/i18n.md +51 -0
  101. package/resources/docs/processes.md +87 -0
  102. package/resources/docs/project.md +101 -0
  103. package/resources/docs/queries.md +54 -0
  104. package/resources/docs/tables.md +97 -0
@@ -36,9 +36,10 @@ const ELEMENT_BY_BUILDER = {
36
36
  /** Modifiers making a column non nullable */
37
37
  const REQUIRED_MODIFIERS = ['notNull', 'required', 'primary'];
38
38
  /**
39
- * Builds the two files describing the database of a project out of its 'defineEntity' declarations:
40
- * 'db-schema.xml', read by the runtime to migrate the database, and 'db-schema.ts', the typed
41
- * context the processes use through `ctx.tables`.
39
+ * Builds the two files describing the database of a project out of its 'defineEntity' and
40
+ * 'defineDocument' declarations: 'db-schema.xml', read by the runtime to migrate the database,
41
+ * and 'db-schema.d.ts', which augments the 'ProjectTables' and 'ProjectDocs' interfaces of
42
+ * '@codenotch/process' so that `ctx.tables.<name>` is typed in the processes.
42
43
  */
43
44
  class DbSchemaUtils {
44
45
  /**
@@ -145,25 +146,39 @@ class DbSchemaUtils {
145
146
  return [` <${element} ${attributes.join(' ')}/>`];
146
147
  }
147
148
  /**
148
- * 'db-schema.ts', the typed database context of the project
149
+ * 'db-schema.d.ts', the declaration merging file typing `ctx.tables` and the documents:
150
+ * it augments '@codenotch/process' with one typed handle per table and per document.
151
+ *
152
+ * The file must stay a module (have a top level import) for the `declare module` block to be
153
+ * an augmentation: as a plain script it would *declare* '@codenotch/process' instead of
154
+ * merging into it. It also only applies to files of the same TypeScript program, hence the
155
+ * tsconfig of the project has to include it.
149
156
  *
150
157
  * @param tables tables of the project, see ProjectUtils.discoverTableFiles
151
- * @param projectName name of the project, used for the interface name
152
- * @param imports import line of each table type, keyed by table name
158
+ * @param documents documents of the project, see ProjectUtils.discoverDocumentFiles
159
+ * @param tableImports import line of each table row type, keyed by table name
160
+ * @param documentImports import line of each document type, keyed by document name
153
161
  */
154
- static generateTs(tables, projectName, imports) {
162
+ static generateDts(tables, documents, tableImports, documentImports) {
155
163
  const warnings = [];
156
164
  // Types coming from the same file share one import statement, as a developer would write it
157
165
  const typesBySpecifier = new Map();
158
- const properties = [];
166
+ const collectImport = (importLine) => {
167
+ const typeNames = typesBySpecifier.get(importLine.specifier) ?? [];
168
+ if (!typeNames.includes(importLine.typeName)) {
169
+ typesBySpecifier.set(importLine.specifier, [...typeNames, importLine.typeName]);
170
+ }
171
+ };
172
+ // ProjectTables: one handle per table, under its collection name
173
+ const tableProperties = [];
159
174
  const collectionNames = new Map();
160
175
  for (const table of this.sortByName(tables)) {
161
176
  if (table.name === undefined) {
162
177
  continue; // already reported by generateXml
163
178
  }
164
- const importLine = this.parseImport(imports.get(table.name));
179
+ const importLine = this.parseImport(tableImports.get(table.name));
165
180
  if (table.typeName === undefined || importLine === undefined) {
166
- warnings.push(`The table '${table.name}' has no exported row type ('export type I${table.name} = InferEntity<typeof ${table.variableName ?? table.name}>'), it is left out of the context.`);
181
+ warnings.push(`The table '${table.name}' has no exported row type ('export type I${table.name} = InferEntity<typeof ${table.variableName ?? table.name}>'), it is left out of 'ProjectTables'.`);
167
182
  continue;
168
183
  }
169
184
  const collectionName = this.toCollectionName(table.name);
@@ -173,40 +188,77 @@ class DbSchemaUtils {
173
188
  continue;
174
189
  }
175
190
  collectionNames.set(collectionName, table.name);
176
- typesBySpecifier.set(importLine.specifier, [...(typesBySpecifier.get(importLine.specifier) ?? []), importLine.typeName]);
177
- properties.push(` ${collectionName}: ITable<${table.typeName}>`);
191
+ collectImport(importLine);
192
+ tableProperties.push(` ${collectionName}: TableHandle<${table.typeName}>;`);
193
+ }
194
+ // ProjectDocs: one handle per document, under its lowercased name (documents are not pluralized)
195
+ const documentProperties = [];
196
+ const documentKeys = new Map();
197
+ for (const document of this.sortByName(documents)) {
198
+ if (document.name === undefined) {
199
+ warnings.push(`A document declared at ${document.filePath}:${document.line} has no literal name, it is left out of 'ProjectDocs'.`);
200
+ continue;
201
+ }
202
+ const importLine = this.parseImport(documentImports.get(document.name));
203
+ if (document.typeName === undefined || importLine === undefined) {
204
+ warnings.push(`The document '${document.name}' has no exported type ('export type I${document.name} = InferDocument<typeof ${document.variableName ?? document.name}>'), it is left out of 'ProjectDocs'.`);
205
+ continue;
206
+ }
207
+ const key = document.name.toLowerCase();
208
+ const takenBy = documentKeys.get(key);
209
+ if (takenBy !== undefined) {
210
+ warnings.push(`The documents '${takenBy}' and '${document.name}' both map to '${key}', only the first one is kept.`);
211
+ continue;
212
+ }
213
+ documentKeys.set(key, document.name);
214
+ collectImport(importLine);
215
+ documentProperties.push(` ${key}: DocStoreHandle<${document.typeName}>;`);
216
+ }
217
+ const handles = [
218
+ ...(tableProperties.length > 0 ? ['TableHandle'] : []),
219
+ ...(documentProperties.length > 0 ? ['DocStoreHandle'] : [])
220
+ ];
221
+ const header = [
222
+ `// Generated by 'cn generate dbcontext', do not edit.`,
223
+ `// Augments the 'ProjectTables' and 'ProjectDocs' interfaces of '@codenotch/process' with the`,
224
+ `// tables and documents of this project, so 'ctx.tables.<name>' autocompletes with its row type.`
225
+ ];
226
+ // Nothing usable: an empty 'declare module' with no import would be an ambient declaration
227
+ // shadowing the real package, so the file is written inert instead
228
+ if (handles.length === 0) {
229
+ return { content: [...header, `export {};`, ``].join('\n'), warnings };
230
+ }
231
+ const blocks = [];
232
+ if (tableProperties.length > 0) {
233
+ blocks.push(` interface ProjectTables {`, ...tableProperties, ` }`);
234
+ }
235
+ if (documentProperties.length > 0) {
236
+ if (blocks.length > 0) {
237
+ blocks.push(``);
238
+ }
239
+ blocks.push(` interface ProjectDocs {`, ...documentProperties, ` }`);
178
240
  }
179
- const importLines = [...typesBySpecifier.entries()]
180
- .map(([specifier, typeNames]) => `import { ${typeNames.join(', ')} } from '${specifier}';`);
181
241
  const content = [
182
- `import { ITable, IDbSchema } from '@codenotch/orm'`,
183
- ...importLines,
242
+ ...header,
243
+ `import type { ${handles.join(', ')} } from '@codenotch/process';`,
244
+ ...[...typesBySpecifier.entries()]
245
+ .map(([specifier, typeNames]) => `import type { ${typeNames.join(', ')} } from '${specifier}';`),
184
246
  ``,
185
- `export default interface ${this.toInterfaceName(projectName)} extends IDbSchema {`,
186
- ...properties,
247
+ `declare module '@codenotch/process' {`,
248
+ ...blocks,
187
249
  `}`,
188
250
  ``
189
251
  ].join('\n');
190
252
  return { content, warnings };
191
253
  }
192
- /** 'my project' and 'my-project' both give 'MyProjectDbSchema' */
193
- static toInterfaceName(projectName) {
194
- const name = projectName
195
- .split(/[^A-Za-z0-9$]+/)
196
- .filter(word => word !== '')
197
- .map(word => word.charAt(0).toUpperCase() + word.slice(1))
198
- .join('');
199
- // An interface cannot start with a digit, and an empty name would produce 'DbSchema' alone
200
- return `${/^[A-Za-z_$]/.test(name) ? name : `Project${name}`}DbSchema`;
201
- }
202
254
  /** Splits an import statement back into the type it brings and the file it comes from */
203
255
  static parseImport(statement) {
204
256
  const match = statement?.match(/^import \{\s*([^}\s]+)\s*\} from '([^']+)';?$/);
205
257
  return match === null || match === undefined ? undefined : { typeName: match[1], specifier: match[2] };
206
258
  }
207
- static sortByName(tables) {
259
+ static sortByName(declarations) {
208
260
  // Sorted so that regenerating an unchanged project produces an unchanged file
209
- return [...tables].sort((left, right) => (left.name ?? '').localeCompare(right.name ?? ''));
261
+ return [...declarations].sort((left, right) => (left.name ?? '').localeCompare(right.name ?? ''));
210
262
  }
211
263
  static getDescription(properties) {
212
264
  return typeof properties['description'] === 'string' ? properties['description'] : '';
@@ -1 +1 @@
1
- {"version":3,"file":"DbSchemaUtils.js","sourceRoot":"","sources":["../../src/utils/DbSchemaUtils.ts"],"names":[],"mappings":";;AAEA,kEAAkE;AAClE,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAA2B;IAC/C,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAO9D;;;;GAI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AAQ,CAAC,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1F,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,KAAa;QAC/B,OAAO,KAAK;aACP,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;aACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;aACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;aACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACJ;AA9TD,gCA8TC"}
@@ -0,0 +1,34 @@
1
+ /** A documentation topic shipped with the CLI */
2
+ export interface IDocTopic {
3
+ /** Name the topic is asked by, e.g. 'tables' for 'tables.md' */
4
+ name: string;
5
+ /** Absolute path of its markdown file */
6
+ filePath: string;
7
+ /** One line summary, taken from the first paragraph of the file */
8
+ summary: string;
9
+ }
10
+ /**
11
+ * The reference documentation shipped with the CLI ('resources/docs' of the package), served by
12
+ * 'cn docs'. Written for coding agents as much as for developers: the AGENTS.md of a generated
13
+ * project points here instead of embedding the reference, so the documentation always matches
14
+ * the installed CLI instead of the CLI that once created the project.
15
+ */
16
+ export default abstract class DocsUtils {
17
+ /**
18
+ * 'resources/docs' of the package, resolved from both 'src/utils' (tsx) and 'dist/utils'
19
+ * (build), which sit at the same depth
20
+ */
21
+ static getDocsFolder(): string;
22
+ /**
23
+ * Every topic of the docs folder, preferred ones first. Empty when the folder is missing,
24
+ * which only happens on a broken installation.
25
+ */
26
+ static listTopics(): IDocTopic[];
27
+ /**
28
+ * Content of one topic, undefined when the name is not a listed topic. Only listed names are
29
+ * read, so the argument cannot address a file outside the docs folder.
30
+ */
31
+ static readTopic(name: string): string | undefined;
32
+ /** First non-empty line after the '# ' title of the file, empty when there is none */
33
+ private static readSummary;
34
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs_1 = require("fs");
4
+ const path_1 = require("path");
5
+ /** Topics listed first, in this order; a file that is not here is appended alphabetically */
6
+ const PREFERRED_ORDER = ['project', 'tables', 'processes', 'queries', 'apps', 'i18n'];
7
+ /**
8
+ * The reference documentation shipped with the CLI ('resources/docs' of the package), served by
9
+ * 'cn docs'. Written for coding agents as much as for developers: the AGENTS.md of a generated
10
+ * project points here instead of embedding the reference, so the documentation always matches
11
+ * the installed CLI instead of the CLI that once created the project.
12
+ */
13
+ class DocsUtils {
14
+ /**
15
+ * 'resources/docs' of the package, resolved from both 'src/utils' (tsx) and 'dist/utils'
16
+ * (build), which sit at the same depth
17
+ */
18
+ static getDocsFolder() {
19
+ return (0, path_1.join)(__dirname, '../../resources/docs');
20
+ }
21
+ /**
22
+ * Every topic of the docs folder, preferred ones first. Empty when the folder is missing,
23
+ * which only happens on a broken installation.
24
+ */
25
+ static listTopics() {
26
+ let files;
27
+ try {
28
+ files = (0, fs_1.readdirSync)(this.getDocsFolder()).filter(file => file.endsWith('.md'));
29
+ }
30
+ catch {
31
+ return [];
32
+ }
33
+ const topics = files.map(file => {
34
+ const filePath = (0, path_1.join)(this.getDocsFolder(), file);
35
+ return {
36
+ name: file.slice(0, -'.md'.length),
37
+ filePath,
38
+ summary: this.readSummary(filePath)
39
+ };
40
+ });
41
+ const rank = (topic) => {
42
+ const index = PREFERRED_ORDER.indexOf(topic.name);
43
+ return index === -1 ? PREFERRED_ORDER.length : index;
44
+ };
45
+ return topics.sort((a, b) => rank(a) - rank(b) || a.name.localeCompare(b.name));
46
+ }
47
+ /**
48
+ * Content of one topic, undefined when the name is not a listed topic. Only listed names are
49
+ * read, so the argument cannot address a file outside the docs folder.
50
+ */
51
+ static readTopic(name) {
52
+ const topic = this.listTopics().find(candidate => candidate.name === name);
53
+ if (topic === undefined) {
54
+ return undefined;
55
+ }
56
+ try {
57
+ return (0, fs_1.readFileSync)(topic.filePath, 'utf8');
58
+ }
59
+ catch {
60
+ return undefined;
61
+ }
62
+ }
63
+ /** First non-empty line after the '# ' title of the file, empty when there is none */
64
+ static readSummary(filePath) {
65
+ try {
66
+ const lines = (0, fs_1.readFileSync)(filePath, 'utf8').split(/\r?\n/);
67
+ const titleIndex = lines.findIndex(line => line.startsWith('# '));
68
+ return lines.slice(titleIndex + 1).find(line => line.trim() !== '')?.trim() ?? '';
69
+ }
70
+ catch {
71
+ return '';
72
+ }
73
+ }
74
+ }
75
+ exports.default = DocsUtils;
76
+ //# sourceMappingURL=DocsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocsUtils.js","sourceRoot":"","sources":["../../src/utils/DocsUtils.ts"],"names":[],"mappings":";;AAAA,2BAA+C;AAC/C,+BAA4B;AAY5B,6FAA6F;AAC7F,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtF;;;;;GAKG;AACH,MAA8B,SAAS;IAEnC;;;OAGG;IACH,MAAM,CAAC,aAAa;QAChB,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU;QAEb,IAAI,KAAe,CAAC;QACpB,IAAI,CAAC;YACD,KAAK,GAAG,IAAA,gBAAW,EAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,CAAC;YACH,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC5B,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;YAClD,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAA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CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YAClE,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACtF,CAAC;QACD,MAAM,CAAC;YACH,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ;AAtED,4BAsEC"}
@@ -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
  }
@@ -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,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;YACvB,KAAK,OAAO;gBACR,OAAO,GAAG,aAAa,GAAG,GAAG,CAAC;gBAC9B,MAAM;YACV,KAAK,QAAQ;gBACT,OAAO,GAAG,SAAS,GAAG,GAAG,CAAC;gBAC1B,MAAM;YACV;gBACI,oCAAoC;gBACpC,OAAO,GAAG,aAAa,GAAG,GAAG,CAAC;gBAC9B,MAAM;QACd,CAAC;QAED,IAAA,oBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,IAAI,KAAK,EAAE,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9D,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA7BD,0BA6BC"}
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,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;YACvB,KAAK,OAAO;gBACR,OAAO,GAAG,aAAa,GAAG,GAAG,CAAC;gBAC9B,MAAM;YACV,KAAK,QAAQ;gBACT,OAAO,GAAG,SAAS,GAAG,GAAG,CAAC;gBAC1B,MAAM;YACV;gBACI,oCAAoC;gBACpC,OAAO,GAAG,aAAa,GAAG,GAAG,CAAC;gBAC9B,MAAM;QACd,CAAC;QAED,IAAA,oBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,IAAI,KAAK,EAAE,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9D,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAkB;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
+ }