@parall/cli 1.81.0 → 1.83.0

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.
@@ -17,7 +17,7 @@ export function cliVersion(command) {
17
17
  /** The error for an id this CLI does not carry: what it has, and that the
18
18
  * template may be newer than this CLI. */
19
19
  export function unknownTemplateError(id, version) {
20
- const known = APP_TEMPLATES.map(({ id: known, intro }) => `${known} (${intro.name.en}; ${intro.name.zh})`).join(', ');
20
+ const known = APP_TEMPLATES.map(({ id: known, intro }) => `${known} (${intro.name})`).join(', ');
21
21
  return new Error(`No app template ${JSON.stringify(id)} in this CLI (parall ${version}); it has: ${known || 'none'}. ` +
22
22
  'A template may be newer than this CLI: update it once — npm install -g @parall/cli@latest, ' +
23
23
  'or where that is not allowed npm install --prefix ~/.parall-cli @parall/cli@latest — ' +
@@ -20,6 +20,15 @@ export declare function resolveInitTarget(raw: string): Promise<InitTarget>;
20
20
  export declare function templateRefusal(template: AppTemplate, target: InitTarget): string | undefined;
21
21
  /** The project's files, sorted by path. */
22
22
  export declare function templateProject(name: string, template: AppTemplate): Array<[string, string]>;
23
+ /** The `--actions` scaffold with the template's overlay over it, sorted by
24
+ * path: the project before init adds the skill and the template's blocks.
25
+ * Named {{APP_NAME}}, it is the project a template version carries
26
+ * (mini-app-template-registry-design.md §4). */
27
+ export declare function templateProjectFiles(name: string, template: AppTemplate): Array<[string, string]>;
28
+ /** The project with the template's skill as SKILL.md and, under the title
29
+ * of AGENTS.md, the line that points to it: what init writes beside the
30
+ * project, sorted by path. */
31
+ export declare function withTemplateSkill(project: ReadonlyArray<readonly [string, string]>, template: AppTemplate): Array<[string, string]>;
23
32
  /** The blocks the template names (_overlay.json `blocks`). */
24
33
  export declare function templateBlocks(template: AppTemplate): string[];
25
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"apps-template-init.d.ts","sourceRoot":"","sources":["../../src/commands/apps-template-init.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,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AAC,CAAC,EAAE;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;CACpB,GAAG,MAAM,CAcT"}
@@ -25,13 +25,22 @@ export function templateRefusal(template, target) {
25
25
  'actions would not run there. Nothing was written. Templates have no MySQL version yet — ' +
26
26
  'tell the person this template cannot be used for this app.');
27
27
  }
28
- /** The line init puts under the title of AGENTS.md. */
28
+ /** The line init puts under the title of AGENTS.md (in English, as the
29
+ * template and its SKILL.md are). */
29
30
  function skillPointer(template) {
30
- return (`> 这个项目由应用模板「${template.intro.name.zh}」(\`${template.id}\`)生成,` +
31
- '模板的页面、action 与表换掉了下文提到的示例;日常工作照 `SKILL.md`。');
31
+ return (`> Built from the app template "${template.intro.name}" (\`${template.id}\`): ` +
32
+ 'its pages, actions and tables replace the example described below. ' +
33
+ 'For day-to-day work, follow `SKILL.md`.');
32
34
  }
33
35
  /** The project's files, sorted by path. */
34
36
  export function templateProject(name, template) {
37
+ return withTemplateSkill(templateProjectFiles(name, template), template);
38
+ }
39
+ /** The `--actions` scaffold with the template's overlay over it, sorted by
40
+ * path: the project before init adds the skill and the template's blocks.
41
+ * Named {{APP_NAME}}, it is the project a template version carries
42
+ * (mini-app-template-registry-design.md §4). */
43
+ export function templateProjectFiles(name, template) {
35
44
  const files = new Map(scaffoldProject({ name, actions: true }));
36
45
  const pkg = files.get('package.json');
37
46
  applyOverlay(files, template.overlay);
@@ -44,11 +53,21 @@ export function templateProject(name, template) {
44
53
  }
45
54
  files.set('package.json', `${JSON.stringify(merged, null, 2)}\n`);
46
55
  }
56
+ return sortedByPath(files);
57
+ }
58
+ /** The project with the template's skill as SKILL.md and, under the title
59
+ * of AGENTS.md, the line that points to it: what init writes beside the
60
+ * project, sorted by path. */
61
+ export function withTemplateSkill(project, template) {
62
+ const files = new Map(project);
47
63
  files.set('SKILL.md', template.skill);
48
64
  const agents = (files.get('AGENTS.md') ?? '').split('\n');
49
65
  const at = agents[0]?.startsWith('# ') ? 1 : 0;
50
66
  agents.splice(at, 0, ...(at ? ['', skillPointer(template)] : [skillPointer(template), '']));
51
67
  files.set('AGENTS.md', agents.join('\n'));
68
+ return sortedByPath(files);
69
+ }
70
+ function sortedByPath(files) {
52
71
  return [...files].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
53
72
  }
54
73
  /** The blocks the template names (_overlay.json `blocks`). */
@@ -104,7 +123,7 @@ export async function writeTemplateProject(out, files, blocks) {
104
123
  export function templateNextSteps(p) {
105
124
  const app = p.target.appId;
106
125
  return [
107
- `Scaffolded ${p.name} from the ${p.template.id} template (${p.template.intro.name.en}) in ${p.out}, for ${app}: its Database ${p.target.databaseId} is PostgreSQL.`,
126
+ `Scaffolded ${p.name} from the ${p.template.id} template (${p.template.intro.name}) in ${p.out}, for ${app}: its Database ${p.target.databaseId} is PostgreSQL.`,
108
127
  'SKILL.md is the template’s skill and AGENTS.md points to it: follow SKILL.md from here.',
109
128
  '',
110
129
  'Next steps (SKILL.md has the details):',
@@ -12,6 +12,14 @@ export interface ScaffoldOptions {
12
12
  }
13
13
  /** The project's files, sorted by path. */
14
14
  export declare function scaffoldProject(options: ScaffoldOptions): Array<[string, string]>;
15
+ /**
16
+ * Names a project whose app name was left as {{APP_NAME}} — the project a
17
+ * template version carries, scaffold, overlay and blocks already laid
18
+ * together (mini-app-template-registry-design.md §4) — the way
19
+ * scaffoldProject names one: the placeholder takes the name, escaped in HTML
20
+ * files, and package.json's name is the npm-valid form of it.
21
+ */
22
+ export declare function nameProject(files: ReadonlyArray<readonly [string, string]>, name: string): Array<[string, string]>;
15
23
  /** An npm-valid package name from a directory name ("My App" → "my-app"). */
16
24
  export declare function packageName(name: string): string;
17
25
  /** Applies the --actions overlay: _overlay.json's remove list drops base
@@ -1 +1 @@
1
- {"version":3,"file":"apps-template.d.ts","sourceRoot":"","sources":["../../src/commands/apps-template.ts"],"names":[],"mappings":"AA+BA;mBACmB;AACnB,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB;4CACwC;IACxC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA8BjF;AAMD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;;eAGe;AACf,wBAAgB,YAAY,CAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAoB1C;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAO/D;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAIxE"}
1
+ {"version":3,"file":"apps-template.d.ts","sourceRoot":"","sources":["../../src/commands/apps-template.ts"],"names":[],"mappings":"AA+BA;mBACmB;AACnB,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB;4CACwC;IACxC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA8BjF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC/C,IAAI,EAAE,MAAM,GACX,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAYzB;AAMD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;;eAGe;AACf,wBAAgB,YAAY,CAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAoB1C;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAO/D;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAIxE"}
@@ -57,6 +57,26 @@ export function scaffoldProject(options) {
57
57
  }
58
58
  return out.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
59
59
  }
60
+ /**
61
+ * Names a project whose app name was left as {{APP_NAME}} — the project a
62
+ * template version carries, scaffold, overlay and blocks already laid
63
+ * together (mini-app-template-registry-design.md §4) — the way
64
+ * scaffoldProject names one: the placeholder takes the name, escaped in HTML
65
+ * files, and package.json's name is the npm-valid form of it.
66
+ */
67
+ export function nameProject(files, name) {
68
+ return files.map(([path, content]) => {
69
+ let named = content;
70
+ if (path === 'package.json') {
71
+ const pkg = JSON.parse(content);
72
+ pkg.name = packageName(name);
73
+ named = `${JSON.stringify(pkg, null, 2)}\n`;
74
+ }
75
+ const value = path.endsWith('.html') ? escapeHtml(name) : name;
76
+ // A function, so a `$&` in the name is not a replacement pattern.
77
+ return [path, named.replace(NAME_PLACEHOLDER, () => value)];
78
+ });
79
+ }
60
80
  function escapeHtml(text) {
61
81
  return text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
62
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"apps-templates.gen.d.ts","sourceRoot":"","sources":["../../src/commands/apps-templates.gen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0D1D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBlE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAyclD,CAAC"}
1
+ {"version":3,"file":"apps-templates.gen.d.ts","sourceRoot":"","sources":["../../src/commands/apps-templates.gen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0D1D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBlE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM3D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAyclD,CAAC"}