@contember/create 2.2.0-alpha.1 → 2.2.0-alpha.10

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 (96) hide show
  1. package/CLAUDE.md +22 -0
  2. package/dist/development/run.cjs +7 -7
  3. package/dist/development/run.cjs.map +1 -1
  4. package/dist/development/run.js +8 -8
  5. package/dist/development/run.js.map +1 -1
  6. package/dist/development/src/commands/WorkspaceCreateCommand.cjs +27 -13
  7. package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  8. package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
  9. package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
  10. package/dist/development/src/lib/TemplateInstaller.cjs +72 -60
  11. package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
  12. package/dist/development/src/lib/TemplateInstaller.js +72 -60
  13. package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
  14. package/dist/production/run.cjs +7 -7
  15. package/dist/production/run.cjs.map +1 -1
  16. package/dist/production/run.js +8 -8
  17. package/dist/production/run.js.map +1 -1
  18. package/dist/production/src/commands/WorkspaceCreateCommand.cjs +27 -13
  19. package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  20. package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
  21. package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
  22. package/dist/production/src/lib/TemplateInstaller.cjs +72 -60
  23. package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
  24. package/dist/production/src/lib/TemplateInstaller.js +72 -60
  25. package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
  26. package/dist/types/commands/WorkspaceCreateCommand.d.ts +15 -3
  27. package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
  28. package/dist/types/lib/FileSystem.d.ts.map +1 -1
  29. package/dist/types/lib/TemplateInstaller.d.ts +9 -1
  30. package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +2 -2
  33. package/resources/templates/default/README.md +3 -1
  34. package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
  35. package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
  36. package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
  37. package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
  38. package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
  39. package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
  40. package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
  41. package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
  42. package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
  43. package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
  44. package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
  45. package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
  46. package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
  47. package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
  48. package/resources/templates/default/admin/lib/tenant/dict.ts +450 -4
  49. package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
  50. package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
  51. package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
  52. package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
  53. package/resources/templates/default/admin/lib/tenant/forms/common.tsx +9 -2
  54. package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
  55. package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
  56. package/resources/templates/default/admin/lib/tenant/forms/index.ts +11 -0
  57. package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +42 -4
  58. package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -10
  59. package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +3 -1
  60. package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
  61. package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -10
  62. package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
  63. package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
  64. package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
  65. package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
  66. package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
  67. package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
  68. package/resources/templates/default/admin/lib/tenant/index.ts +7 -0
  69. package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +160 -22
  70. package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
  71. package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
  72. package/resources/templates/default/admin/lib/tenant/listing/index.ts +7 -0
  73. package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +1 -1
  74. package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +20 -11
  75. package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
  76. package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
  77. package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
  78. package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +13 -2
  79. package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
  80. package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
  81. package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
  82. package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
  83. package/resources/templates/default/admin/lib/tenant/otp/index.ts +2 -0
  84. package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
  85. package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
  86. package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
  87. package/resources/templates/default/admin/package.json +1 -0
  88. package/resources/templates/default/docker/object-storage/README.md +13 -0
  89. package/resources/templates/default/docker/object-storage/identities.json +13 -0
  90. package/resources/templates/default/docker-compose.yaml +29 -7
  91. package/src/commands/WorkspaceCreateCommand.ts +42 -14
  92. package/src/lib/TemplateInstaller.ts +87 -69
  93. package/src/run.ts +8 -7
  94. package/tests/cases/unit/create-process.test.ts +66 -0
  95. package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
  96. package/tests/cases/unit/workspace-create.test.ts +81 -0
@@ -1,81 +1,93 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const path = require("node:path");
4
- const jsyaml = require("js-yaml");
5
4
  const degit = require("degit");
5
+ const jsyaml = require("js-yaml");
6
6
  var __defProp = Object.defineProperty;
7
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
8
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ const cloneTemplate = async (source, target) => {
10
+ const emitter = degit(source, { cache: false, force: true, verbose: true });
11
+ await emitter.clone(target);
12
+ };
9
13
  class TemplateInstaller {
10
- constructor(resourceDir, fs) {
14
+ constructor(resourceDir, fs, output, clone = cloneTemplate) {
11
15
  this.resourceDir = resourceDir;
12
16
  this.fs = fs;
17
+ this.output = output;
18
+ this.clone = clone;
13
19
  __publicField(this, "localTemplates");
14
20
  __publicField(this, "installTemplate", async (template, targetDir, variables = {}) => {
15
- let removeTemplate = () => {
16
- };
21
+ let temporaryTemplateDir;
22
+ let remoteTemplate;
17
23
  if (this.localTemplates[template]) {
18
24
  template = this.localTemplates[template];
19
25
  } else {
20
- const tmpDir = await this.fs.createTempDir();
21
- try {
22
- const emitter = degit(template, { cache: false, force: true, verbose: true });
23
- await emitter.clone(tmpDir);
24
- removeTemplate = () => {
25
- try {
26
- this.fs.remove(tmpDir, { recursive: true, force: true });
27
- } catch (error) {
28
- console.error(`Failed to clean up template: ${error}`);
29
- }
30
- };
31
- template = tmpDir;
32
- } catch (error) {
33
- throw new Error(`Failed to clone template from repository: ${error}`);
34
- }
35
- }
36
- const templateConfigFile = path.join(template, "contember.template.yaml");
37
- if (!await this.fs.pathExists(templateConfigFile)) {
38
- removeTemplate();
39
- throw new Error(`${template} is not a Contember template`);
40
- }
41
- const config = await this.readYaml(templateConfigFile);
42
- const nodeModulesDir = path.join(template, "node_modules");
43
- const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => path.join(template, it)), templateConfigFile]);
44
- if (await this.fs.pathExists(targetDir)) {
45
- throw `${targetDir} already exists`;
26
+ remoteTemplate = template;
27
+ temporaryTemplateDir = await this.fs.createTempDir();
28
+ template = temporaryTemplateDir;
46
29
  }
47
- await this.fs.copy(template, targetDir, {
48
- filter: (src) => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src)
49
- });
50
- removeTemplate();
51
- if (config.patchPackageJson) {
52
- await this.replaceFileContent(path.join(targetDir, "package.json"), (content) => {
53
- const {
54
- name,
55
- version,
56
- "scripts-template": scripts,
57
- scripts: _nullScripts,
58
- license,
59
- ...json
60
- } = JSON.parse(content);
61
- return JSON.stringify({ scripts, ...json }, null, " ");
30
+ try {
31
+ if (remoteTemplate !== void 0) {
32
+ try {
33
+ await this.clone(remoteTemplate, template);
34
+ } catch (error) {
35
+ throw new Error(`Failed to clone template from repository: ${error}`);
36
+ }
37
+ }
38
+ const templateConfigFile = path.join(template, "contember.template.yaml");
39
+ if (!await this.fs.pathExists(templateConfigFile)) {
40
+ throw new Error(`${template} is not a Contember template`);
41
+ }
42
+ const config = await this.readYaml(templateConfigFile);
43
+ const nodeModulesDir = path.join(template, "node_modules");
44
+ const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => path.join(template, it)), templateConfigFile]);
45
+ if (await this.fs.pathExists(targetDir)) {
46
+ throw `${targetDir} already exists`;
47
+ }
48
+ await this.fs.copy(template, targetDir, {
49
+ filter: (src) => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src)
62
50
  });
63
- }
64
- for (const [source, target] of Object.entries(config.rename || {})) {
65
- await this.fs.rename(path.join(targetDir, source), path.join(targetDir, target));
66
- }
67
- for (const [source, target] of Object.entries(config.copy || {})) {
68
- await this.fs.copy(path.join(targetDir, source), path.join(targetDir, target));
69
- }
70
- for (const file of config.replaceVariables || []) {
71
- const path$1 = path.join(targetDir, file);
72
- if (!await this.fs.pathExists(path$1)) {
73
- continue;
51
+ if (config.patchPackageJson) {
52
+ await this.replaceFileContent(path.join(targetDir, "package.json"), (content) => {
53
+ const {
54
+ name,
55
+ version,
56
+ "scripts-template": scripts,
57
+ scripts: _nullScripts,
58
+ license,
59
+ ...json
60
+ } = JSON.parse(content);
61
+ return JSON.stringify({ scripts, ...json }, null, " ");
62
+ });
63
+ }
64
+ for (const [source, target] of Object.entries(config.rename || {})) {
65
+ await this.fs.rename(path.join(targetDir, source), path.join(targetDir, target));
66
+ }
67
+ for (const [source, target] of Object.entries(config.copy || {})) {
68
+ await this.fs.copy(path.join(targetDir, source), path.join(targetDir, target));
74
69
  }
75
- await this.replaceFileContent(path$1, (content) => Object.entries(variables).reduce(
76
- (content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
77
- content
78
- ));
70
+ for (const file of config.replaceVariables || []) {
71
+ const path$1 = path.join(targetDir, file);
72
+ if (!await this.fs.pathExists(path$1)) {
73
+ continue;
74
+ }
75
+ await this.replaceFileContent(path$1, (content) => Object.entries(variables).reduce(
76
+ (content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
77
+ content
78
+ ));
79
+ }
80
+ } finally {
81
+ if (temporaryTemplateDir !== void 0) {
82
+ await this.cleanupTemporaryTemplate(temporaryTemplateDir);
83
+ }
84
+ }
85
+ });
86
+ __publicField(this, "cleanupTemporaryTemplate", async (path2) => {
87
+ try {
88
+ await this.fs.remove(path2, { recursive: true, force: true });
89
+ } catch {
90
+ this.output.warn("Failed to clean up the temporary template directory.");
79
91
  }
80
92
  });
81
93
  __publicField(this, "replaceFileContent", async (path2, replacer) => {
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateInstaller.cjs","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { FileSystem } from './FileSystem.js'\nimport jsyaml from 'js-yaml'\nimport degit from 'degit'\n\nexport class TemplateInstaller {\n\tprivate localTemplates: Record<string, string>\n\n\tconstructor(\n\t\tprivate readonly resourceDir: string,\n\t\tprivate readonly fs: FileSystem,\n\t) {\n\t\tthis.localTemplates = {\n\t\t\t['default']: join(this.resourceDir, 'templates/default'),\n\t\t}\n\t}\n\n\tinstallTemplate = async (\n\t\ttemplate: string,\n\t\ttargetDir: string,\n\t\tvariables: Record<string, string> = {},\n\t) => {\n\t\tlet removeTemplate = () => {}\n\n\t\tif (this.localTemplates[template]) {\n\t\t\ttemplate = this.localTemplates[template]\n\t\t} else {\n\t\t\tconst tmpDir = await this.fs.createTempDir()\n\n\t\t\ttry {\n\t\t\t\tconst emitter = degit(template, { cache: false, force: true, verbose: true })\n\t\t\t\tawait emitter.clone(tmpDir)\n\n\t\t\t\tremoveTemplate = () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.fs.remove(tmpDir, { recursive: true, force: true })\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error(`Failed to clean up template: ${error}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttemplate = tmpDir\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Failed to clone template from repository: ${error}`)\n\t\t\t}\n\t\t}\n\n\t\tconst templateConfigFile = join(template, 'contember.template.yaml')\n\t\tif (!(await this.fs.pathExists(templateConfigFile))) {\n\t\t\tremoveTemplate()\n\t\t\tthrow new Error(`${template} is not a Contember template`)\n\t\t}\n\t\tconst config = (await this.readYaml(templateConfigFile)) as {\n\t\t\ttype?: string\n\t\t\tremove?: string[]\n\t\t\tpatchPackageJson?: boolean\n\t\t\trename?: Record<string, string>\n\t\t\tcopy?: Record<string, string>\n\t\t\treplaceVariables?: string[]\n\t\t}\n\t\tconst nodeModulesDir = join(template, 'node_modules')\n\t\tconst skippedFiles = new Set([...(config.remove || []).map(it => join(template, it)), templateConfigFile])\n\t\tif (await this.fs.pathExists(targetDir)) {\n\t\t\tthrow `${targetDir} already exists`\n\t\t}\n\t\tawait this.fs.copy(template, targetDir, {\n\t\t\tfilter: src => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src),\n\t\t})\n\n\t\tremoveTemplate()\n\n\t\tif (config.patchPackageJson) {\n\t\t\tawait this.replaceFileContent(join(targetDir, 'package.json'), content => {\n\t\t\t\tconst {\n\t\t\t\t\tname,\n\t\t\t\t\tversion,\n\t\t\t\t\t'scripts-template': scripts,\n\t\t\t\t\tscripts: _nullScripts,\n\t\t\t\t\tlicense,\n\t\t\t\t\t...json\n\t\t\t\t} = JSON.parse(content)\n\t\t\t\treturn JSON.stringify({ scripts, ...json }, null, ' ')\n\t\t\t})\n\t\t}\n\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\tawait this.fs.rename(join(targetDir, source), join(targetDir, target))\n\t\t}\n\t\tfor (const [source, target] of Object.entries(config.copy || {})) {\n\t\t\tawait this.fs.copy(join(targetDir, source), join(targetDir, target))\n\t\t}\n\n\t\tfor (const file of config.replaceVariables || []) {\n\t\t\tconst path = join(targetDir, file)\n\t\t\tif (!(await this.fs.pathExists(path))) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tawait this.replaceFileContent(path, content =>\n\t\t\t\tObject.entries(variables).reduce(\n\t\t\t\t\t(content, [key, value]) => content.replace(new RegExp(`{${key}}`, 'g'), value),\n\t\t\t\t\tcontent,\n\t\t\t\t))\n\t\t}\n\t}\n\n\tprivate replaceFileContent = async (path: string, replacer: (content: string) => string): Promise<void> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\tconst newContent = replacer(content)\n\t\tawait this.fs.writeFile(path, newContent, { encoding: 'utf8' })\n\t}\n\n\tprivate readYaml = async <T = unknown>(path: string): Promise<T> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\treturn jsyaml.load(content) as unknown as T\n\t}\n}\n"],"names":["join","path","content"],"mappings":";;;;;;;;AAKO,MAAM,kBAAkB;AAAA,EAG9B,YACkB,aACA,IAChB;AAFgB,SAAA,cAAA;AACA,SAAA,KAAA;AAJlB,kBAAA,MAAQ,gBAAA;AAWR,kBAAA,MAAA,mBAAkB,OACjB,UACA,WACA,YAAoC,OAChC;AACJ,UAAI,iBAAiB,MAAM;AAAA,MAAC;AAE5B,UAAI,KAAK,eAAe,QAAQ,GAAG;AAClC,mBAAW,KAAK,eAAe,QAAQ;AAAA,MACxC,OAAO;AACN,cAAM,SAAS,MAAM,KAAK,GAAG,cAAA;AAE7B,YAAI;AACH,gBAAM,UAAU,MAAM,UAAU,EAAE,OAAO,OAAO,OAAO,MAAM,SAAS,MAAM;AAC5E,gBAAM,QAAQ,MAAM,MAAM;AAE1B,2BAAiB,MAAM;AACtB,gBAAI;AACH,mBAAK,GAAG,OAAO,QAAQ,EAAE,WAAW,MAAM,OAAO,MAAM;AAAA,YACxD,SAAS,OAAO;AACf,sBAAQ,MAAM,gCAAgC,KAAK,EAAE;AAAA,YACtD;AAAA,UACD;AAEA,qBAAW;AAAA,QACZ,SAAS,OAAO;AACf,gBAAM,IAAI,MAAM,6CAA6C,KAAK,EAAE;AAAA,QACrE;AAAA,MACD;AAEA,YAAM,qBAAqBA,KAAAA,KAAK,UAAU,yBAAyB;AACnE,UAAI,CAAE,MAAM,KAAK,GAAG,WAAW,kBAAkB,GAA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AEA,iBAAW,QAAQ,OAAO,oBAAoB,CAAA,GAAI;AACjD,cAAMC,SAAOD,KAAAA,KAAK,WAAW,IAAI;AACjC,YAAI,CAAE,MAAM,KAAK,GAAG,WAAWC,MAAI,GAAI;AACtC;AAAA,QACD;AACA,cAAM,KAAK,mBAAmBA,QAAM,aACnC,OAAO,QAAQ,SAAS,EAAE;AAAA,UACzB,CAACC,UAAS,CAAC,KAAK,KAAK,MAAMA,SAAQ,QAAQ,IAAI,OAAO,IAAI,GAAG,KAAK,GAAG,GAAG,KAAK;AAAA,UAC7E;AAAA,QAAA,CACA;AAAA,MACH;AAAA,IACD,CAAA;AAEA,kBAAA,MAAQ,sBAAqB,OAAOD,OAAc,aAAyD;AAC1G,YAAM,UAAU,MAAM,KAAK,GAAG,SAASA,OAAM,EAAE,UAAU,QAAQ;AACjE,YAAM,aAAa,SAAS,OAAO;AACnC,YAAM,KAAK,GAAG,UAAUA,OAAM,YAAY,EAAE,UAAU,QAAQ;AAAA,IAC/D,CAAA;AAEA,kBAAA,MAAQ,YAAW,OAAoBA,UAA6B;AACnE,YAAM,UAAU,MAAM,KAAK,GAAG,SAASA,OAAM,EAAE,UAAU,QAAQ;AACjE,aAAO,OAAO,KAAK,OAAO;AAAA,IAC3B,CAAA;AArGC,SAAK,iBAAiB;AAAA,MACrB,CAAC,SAAS,GAAGD,KAAAA,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AAmGD;;"}
1
+ {"version":3,"file":"TemplateInstaller.cjs","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport degit from 'degit'\nimport jsyaml from 'js-yaml'\nimport { FileSystem } from './FileSystem.js'\n\ninterface TemplateInstallerOutput {\n\twarn(message: string): void\n}\n\ntype CloneTemplate = (source: string, target: string) => Promise<void>\n\nconst cloneTemplate: CloneTemplate = async (source, target) => {\n\tconst emitter = degit(source, { cache: false, force: true, verbose: true })\n\tawait emitter.clone(target)\n}\n\nexport class TemplateInstaller {\n\tprivate localTemplates: Record<string, string>\n\n\tconstructor(\n\t\tprivate readonly resourceDir: string,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly output: TemplateInstallerOutput,\n\t\tprivate readonly clone: CloneTemplate = cloneTemplate,\n\t) {\n\t\tthis.localTemplates = {\n\t\t\t['default']: join(this.resourceDir, 'templates/default'),\n\t\t}\n\t}\n\n\tinstallTemplate = async (\n\t\ttemplate: string,\n\t\ttargetDir: string,\n\t\tvariables: Record<string, string> = {},\n\t) => {\n\t\tlet temporaryTemplateDir: string | undefined\n\t\tlet remoteTemplate: string | undefined\n\n\t\tif (this.localTemplates[template]) {\n\t\t\ttemplate = this.localTemplates[template]\n\t\t} else {\n\t\t\tremoteTemplate = template\n\t\t\ttemporaryTemplateDir = await this.fs.createTempDir()\n\t\t\ttemplate = temporaryTemplateDir\n\t\t}\n\n\t\ttry {\n\t\t\tif (remoteTemplate !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.clone(remoteTemplate, template)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(`Failed to clone template from repository: ${error}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst templateConfigFile = join(template, 'contember.template.yaml')\n\t\t\tif (!(await this.fs.pathExists(templateConfigFile))) {\n\t\t\t\tthrow new Error(`${template} is not a Contember template`)\n\t\t\t}\n\t\t\tconst config = (await this.readYaml(templateConfigFile)) as {\n\t\t\t\ttype?: string\n\t\t\t\tremove?: string[]\n\t\t\t\tpatchPackageJson?: boolean\n\t\t\t\trename?: Record<string, string>\n\t\t\t\tcopy?: Record<string, string>\n\t\t\t\treplaceVariables?: string[]\n\t\t\t}\n\t\t\tconst nodeModulesDir = join(template, 'node_modules')\n\t\t\tconst skippedFiles = new Set([...(config.remove || []).map(it => join(template, it)), templateConfigFile])\n\t\t\tif (await this.fs.pathExists(targetDir)) {\n\t\t\t\tthrow `${targetDir} already exists`\n\t\t\t}\n\t\t\tawait this.fs.copy(template, targetDir, {\n\t\t\t\tfilter: src => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src),\n\t\t\t})\n\n\t\t\tif (config.patchPackageJson) {\n\t\t\t\tawait this.replaceFileContent(join(targetDir, 'package.json'), content => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tversion,\n\t\t\t\t\t\t'scripts-template': scripts,\n\t\t\t\t\t\tscripts: _nullScripts,\n\t\t\t\t\t\tlicense,\n\t\t\t\t\t\t...json\n\t\t\t\t\t} = JSON.parse(content)\n\t\t\t\t\treturn JSON.stringify({ scripts, ...json }, null, ' ')\n\t\t\t\t})\n\t\t\t}\n\t\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\t\tawait this.fs.rename(join(targetDir, source), join(targetDir, target))\n\t\t\t}\n\t\t\tfor (const [source, target] of Object.entries(config.copy || {})) {\n\t\t\t\tawait this.fs.copy(join(targetDir, source), join(targetDir, target))\n\t\t\t}\n\n\t\t\tfor (const file of config.replaceVariables || []) {\n\t\t\t\tconst path = join(targetDir, file)\n\t\t\t\tif (!(await this.fs.pathExists(path))) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tawait this.replaceFileContent(path, content =>\n\t\t\t\t\tObject.entries(variables).reduce(\n\t\t\t\t\t\t(content, [key, value]) => content.replace(new RegExp(`{${key}}`, 'g'), value),\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t))\n\t\t\t}\n\t\t} finally {\n\t\t\tif (temporaryTemplateDir !== undefined) {\n\t\t\t\tawait this.cleanupTemporaryTemplate(temporaryTemplateDir)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate cleanupTemporaryTemplate = async (path: string): Promise<void> => {\n\t\ttry {\n\t\t\tawait this.fs.remove(path, { recursive: true, force: true })\n\t\t} catch {\n\t\t\tthis.output.warn('Failed to clean up the temporary template directory.')\n\t\t}\n\t}\n\n\tprivate replaceFileContent = async (path: string, replacer: (content: string) => string): Promise<void> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\tconst newContent = replacer(content)\n\t\tawait this.fs.writeFile(path, newContent, { encoding: 'utf8' })\n\t}\n\n\tprivate readYaml = async <T = unknown>(path: string): Promise<T> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\treturn jsyaml.load(content) as unknown as T\n\t}\n}\n"],"names":["join","path","content"],"mappings":";;;;;;;;AAWA,MAAM,gBAA+B,OAAO,QAAQ,WAAW;AAC9D,QAAM,UAAU,MAAM,QAAQ,EAAE,OAAO,OAAO,OAAO,MAAM,SAAS,MAAM;AAC1E,QAAM,QAAQ,MAAM,MAAM;AAC3B;AAEO,MAAM,kBAAkB;AAAA,EAG9B,YACkB,aACA,IACA,QACA,QAAuB,eACvC;AAJgB,SAAA,cAAA;AACA,SAAA,KAAA;AACA,SAAA,SAAA;AACA,SAAA,QAAA;AANlB,kBAAA,MAAQ,gBAAA;AAaR,kBAAA,MAAA,mBAAkB,OACjB,UACA,WACA,YAAoC,OAChC;AACJ,UAAI;AACJ,UAAI;AAEJ,UAAI,KAAK,eAAe,QAAQ,GAAG;AAClC,mBAAW,KAAK,eAAe,QAAQ;AAAA,MACxC,OAAO;AACN,yBAAiB;AACjB,+BAAuB,MAAM,KAAK,GAAG,cAAA;AACrC,mBAAW;AAAA,MACZ;AAEA,UAAI;AACH,YAAI,mBAAmB,QAAW;AACjC,cAAI;AACH,kBAAM,KAAK,MAAM,gBAAgB,QAAQ;AAAA,UAC1C,SAAS,OAAO;AACf,kBAAM,IAAI,MAAM,6CAA6C,KAAK,EAAE;AAAA,UACrE;AAAA,QACD;AAEA,cAAM,qBAAqBA,KAAAA,KAAK,UAAU,yBAAyB;AACnE,YAAI,CAAE,MAAM,KAAK,GAAG,WAAW,kBAAkB,GAAI;AACpD,gBAAM,IAAI,MAAM,GAAG,QAAQ,8BAA8B;AAAA,QAC1D;AACA,cAAM,SAAU,MAAM,KAAK,SAAS,kBAAkB;A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G,WAAWC,MAAI,GAAI;AACtC;AAAA,UACD;AACA,gBAAM,KAAK,mBAAmBA,QAAM,aACnC,OAAO,QAAQ,SAAS,EAAE;AAAA,YACzB,CAACC,UAAS,CAAC,KAAK,KAAK,MAAMA,SAAQ,QAAQ,IAAI,OAAO,IAAI,GAAG,KAAK,GAAG,GAAG,KAAK;AAAA,YAC7E;AAAA,UAAA,CACA;AAAA,QACH;AAAA,MACD,UAAA;AACC,YAAI,yBAAyB,QAAW;AACvC,gBAAM,KAAK,yBAAyB,oBAAoB;AAAA,QACzD;AAAA,MACD;AAAA,IACD,CAAA;AAEA,kBAAA,MAAQ,4BAA2B,OAAOD,UAAgC;AACzE,UAAI;AACH,cAAM,KAAK,GAAG,OAAOA,OAAM,EAAE,WAAW,MAAM,OAAO,MAAM;AAAA,MAC5D,QAAQ;AACP,aAAK,OAAO,KAAK,sDAAsD;AAAA,MACxE;AAAA,IACD,CAAA;AAEA,kBAAA,MAAQ,sBAAqB,OAAOA,OAAc,aAAyD;AAC1G,YAAM,UAAU,MAAM,KAAK,GAAG,SAASA,OAAM,EAAE,UAAU,QAAQ;AACjE,YAAM,aAAa,SAAS,OAAO;AACnC,YAAM,KAAK,GAAG,UAAUA,OAAM,YAAY,EAAE,UAAU,QAAQ;AAAA,IAC/D,CAAA;AAEA,kBAAA,MAAQ,YAAW,OAAoBA,UAA6B;AACnE,YAAM,UAAU,MAAM,KAAK,GAAG,SAASA,OAAM,EAAE,UAAU,QAAQ;AACjE,aAAO,OAAO,KAAK,OAAO;AAAA,IAC3B,CAAA;AA1GC,SAAK,iBAAiB;AAAA,MACrB,CAAC,SAAS,GAAGD,KAAAA,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AAwGD;;"}
@@ -1,79 +1,91 @@
1
1
  import { join } from "node:path";
2
- import jsyaml__default from "js-yaml";
3
2
  import degit from "degit";
3
+ import jsyaml__default from "js-yaml";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ const cloneTemplate = async (source, target) => {
8
+ const emitter = degit(source, { cache: false, force: true, verbose: true });
9
+ await emitter.clone(target);
10
+ };
7
11
  class TemplateInstaller {
8
- constructor(resourceDir, fs) {
12
+ constructor(resourceDir, fs, output, clone = cloneTemplate) {
9
13
  this.resourceDir = resourceDir;
10
14
  this.fs = fs;
15
+ this.output = output;
16
+ this.clone = clone;
11
17
  __publicField(this, "localTemplates");
12
18
  __publicField(this, "installTemplate", async (template, targetDir, variables = {}) => {
13
- let removeTemplate = () => {
14
- };
19
+ let temporaryTemplateDir;
20
+ let remoteTemplate;
15
21
  if (this.localTemplates[template]) {
16
22
  template = this.localTemplates[template];
17
23
  } else {
18
- const tmpDir = await this.fs.createTempDir();
19
- try {
20
- const emitter = degit(template, { cache: false, force: true, verbose: true });
21
- await emitter.clone(tmpDir);
22
- removeTemplate = () => {
23
- try {
24
- this.fs.remove(tmpDir, { recursive: true, force: true });
25
- } catch (error) {
26
- console.error(`Failed to clean up template: ${error}`);
27
- }
28
- };
29
- template = tmpDir;
30
- } catch (error) {
31
- throw new Error(`Failed to clone template from repository: ${error}`);
32
- }
33
- }
34
- const templateConfigFile = join(template, "contember.template.yaml");
35
- if (!await this.fs.pathExists(templateConfigFile)) {
36
- removeTemplate();
37
- throw new Error(`${template} is not a Contember template`);
24
+ remoteTemplate = template;
25
+ temporaryTemplateDir = await this.fs.createTempDir();
26
+ template = temporaryTemplateDir;
38
27
  }
39
- const config = await this.readYaml(templateConfigFile);
40
- const nodeModulesDir = join(template, "node_modules");
41
- const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => join(template, it)), templateConfigFile]);
42
- if (await this.fs.pathExists(targetDir)) {
43
- throw `${targetDir} already exists`;
44
- }
45
- await this.fs.copy(template, targetDir, {
46
- filter: (src) => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src)
47
- });
48
- removeTemplate();
49
- if (config.patchPackageJson) {
50
- await this.replaceFileContent(join(targetDir, "package.json"), (content) => {
51
- const {
52
- name,
53
- version,
54
- "scripts-template": scripts,
55
- scripts: _nullScripts,
56
- license,
57
- ...json
58
- } = JSON.parse(content);
59
- return JSON.stringify({ scripts, ...json }, null, " ");
28
+ try {
29
+ if (remoteTemplate !== void 0) {
30
+ try {
31
+ await this.clone(remoteTemplate, template);
32
+ } catch (error) {
33
+ throw new Error(`Failed to clone template from repository: ${error}`);
34
+ }
35
+ }
36
+ const templateConfigFile = join(template, "contember.template.yaml");
37
+ if (!await this.fs.pathExists(templateConfigFile)) {
38
+ throw new Error(`${template} is not a Contember template`);
39
+ }
40
+ const config = await this.readYaml(templateConfigFile);
41
+ const nodeModulesDir = join(template, "node_modules");
42
+ const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => join(template, it)), templateConfigFile]);
43
+ if (await this.fs.pathExists(targetDir)) {
44
+ throw `${targetDir} already exists`;
45
+ }
46
+ await this.fs.copy(template, targetDir, {
47
+ filter: (src) => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src)
60
48
  });
61
- }
62
- for (const [source, target] of Object.entries(config.rename || {})) {
63
- await this.fs.rename(join(targetDir, source), join(targetDir, target));
64
- }
65
- for (const [source, target] of Object.entries(config.copy || {})) {
66
- await this.fs.copy(join(targetDir, source), join(targetDir, target));
67
- }
68
- for (const file of config.replaceVariables || []) {
69
- const path = join(targetDir, file);
70
- if (!await this.fs.pathExists(path)) {
71
- continue;
49
+ if (config.patchPackageJson) {
50
+ await this.replaceFileContent(join(targetDir, "package.json"), (content) => {
51
+ const {
52
+ name,
53
+ version,
54
+ "scripts-template": scripts,
55
+ scripts: _nullScripts,
56
+ license,
57
+ ...json
58
+ } = JSON.parse(content);
59
+ return JSON.stringify({ scripts, ...json }, null, " ");
60
+ });
61
+ }
62
+ for (const [source, target] of Object.entries(config.rename || {})) {
63
+ await this.fs.rename(join(targetDir, source), join(targetDir, target));
64
+ }
65
+ for (const [source, target] of Object.entries(config.copy || {})) {
66
+ await this.fs.copy(join(targetDir, source), join(targetDir, target));
72
67
  }
73
- await this.replaceFileContent(path, (content) => Object.entries(variables).reduce(
74
- (content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
75
- content
76
- ));
68
+ for (const file of config.replaceVariables || []) {
69
+ const path = join(targetDir, file);
70
+ if (!await this.fs.pathExists(path)) {
71
+ continue;
72
+ }
73
+ await this.replaceFileContent(path, (content) => Object.entries(variables).reduce(
74
+ (content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
75
+ content
76
+ ));
77
+ }
78
+ } finally {
79
+ if (temporaryTemplateDir !== void 0) {
80
+ await this.cleanupTemporaryTemplate(temporaryTemplateDir);
81
+ }
82
+ }
83
+ });
84
+ __publicField(this, "cleanupTemporaryTemplate", async (path) => {
85
+ try {
86
+ await this.fs.remove(path, { recursive: true, force: true });
87
+ } catch {
88
+ this.output.warn("Failed to clean up the temporary template directory.");
77
89
  }
78
90
  });
79
91
  __publicField(this, "replaceFileContent", async (path, replacer) => {
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateInstaller.js","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { FileSystem } from './FileSystem.js'\nimport jsyaml from 'js-yaml'\nimport degit from 'degit'\n\nexport class TemplateInstaller {\n\tprivate localTemplates: Record<string, string>\n\n\tconstructor(\n\t\tprivate readonly resourceDir: string,\n\t\tprivate readonly fs: FileSystem,\n\t) {\n\t\tthis.localTemplates = {\n\t\t\t['default']: join(this.resourceDir, 'templates/default'),\n\t\t}\n\t}\n\n\tinstallTemplate = async (\n\t\ttemplate: string,\n\t\ttargetDir: string,\n\t\tvariables: Record<string, string> = {},\n\t) => {\n\t\tlet removeTemplate = () => {}\n\n\t\tif (this.localTemplates[template]) {\n\t\t\ttemplate = this.localTemplates[template]\n\t\t} else {\n\t\t\tconst tmpDir = await this.fs.createTempDir()\n\n\t\t\ttry {\n\t\t\t\tconst emitter = degit(template, { cache: false, force: true, verbose: true })\n\t\t\t\tawait emitter.clone(tmpDir)\n\n\t\t\t\tremoveTemplate = () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthis.fs.remove(tmpDir, { recursive: true, force: true })\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error(`Failed to clean up template: ${error}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttemplate = tmpDir\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Failed to clone template from repository: ${error}`)\n\t\t\t}\n\t\t}\n\n\t\tconst templateConfigFile = join(template, 'contember.template.yaml')\n\t\tif (!(await this.fs.pathExists(templateConfigFile))) {\n\t\t\tremoveTemplate()\n\t\t\tthrow new Error(`${template} is not a Contember template`)\n\t\t}\n\t\tconst config = (await this.readYaml(templateConfigFile)) as {\n\t\t\ttype?: string\n\t\t\tremove?: string[]\n\t\t\tpatchPackageJson?: boolean\n\t\t\trename?: Record<string, string>\n\t\t\tcopy?: Record<string, string>\n\t\t\treplaceVariables?: string[]\n\t\t}\n\t\tconst nodeModulesDir = join(template, 'node_modules')\n\t\tconst skippedFiles = new Set([...(config.remove || []).map(it => join(template, it)), templateConfigFile])\n\t\tif (await this.fs.pathExists(targetDir)) {\n\t\t\tthrow `${targetDir} already exists`\n\t\t}\n\t\tawait this.fs.copy(template, targetDir, {\n\t\t\tfilter: src => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src),\n\t\t})\n\n\t\tremoveTemplate()\n\n\t\tif (config.patchPackageJson) {\n\t\t\tawait this.replaceFileContent(join(targetDir, 'package.json'), content => {\n\t\t\t\tconst {\n\t\t\t\t\tname,\n\t\t\t\t\tversion,\n\t\t\t\t\t'scripts-template': scripts,\n\t\t\t\t\tscripts: _nullScripts,\n\t\t\t\t\tlicense,\n\t\t\t\t\t...json\n\t\t\t\t} = JSON.parse(content)\n\t\t\t\treturn JSON.stringify({ scripts, ...json }, null, ' ')\n\t\t\t})\n\t\t}\n\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\tawait this.fs.rename(join(targetDir, source), join(targetDir, target))\n\t\t}\n\t\tfor (const [source, target] of Object.entries(config.copy || {})) {\n\t\t\tawait this.fs.copy(join(targetDir, source), join(targetDir, target))\n\t\t}\n\n\t\tfor (const file of config.replaceVariables || []) {\n\t\t\tconst path = join(targetDir, file)\n\t\t\tif (!(await this.fs.pathExists(path))) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tawait this.replaceFileContent(path, content =>\n\t\t\t\tObject.entries(variables).reduce(\n\t\t\t\t\t(content, [key, value]) => content.replace(new RegExp(`{${key}}`, 'g'), value),\n\t\t\t\t\tcontent,\n\t\t\t\t))\n\t\t}\n\t}\n\n\tprivate replaceFileContent = async (path: string, replacer: (content: string) => string): Promise<void> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\tconst newContent = replacer(content)\n\t\tawait this.fs.writeFile(path, newContent, { encoding: 'utf8' })\n\t}\n\n\tprivate readYaml = async <T = unknown>(path: string): Promise<T> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\treturn jsyaml.load(content) as unknown as T\n\t}\n}\n"],"names":["content","jsyaml"],"mappings":";;;;;;AAKO,MAAM,kBAAkB;AAAA,EAG9B,YACkB,aACA,IAChB;AAFgB,SAAA,cAAA;AACA,SAAA,KAAA;AAJlB,kBAAA,MAAQ,gBAAA;AAWR,kBAAA,MAAA,mBAAkB,OACjB,UACA,WACA,YAAoC,OAChC;AACJ,UAAI,iBAAiB,MAAM;AAAA,MAAC;AAE5B,UAAI,KAAK,eAAe,QAAQ,GAAG;AAClC,mBAAW,KAAK,eAAe,QAAQ;AAAA,MACxC,OAAO;AACN,cAAM,SAAS,MAAM,KAAK,GAAG,cAAA;AAE7B,YAAI;AACH,g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AAA,MACrB,CAAC,SAAS,GAAG,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AAmGD;"}
1
+ {"version":3,"file":"TemplateInstaller.js","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport degit from 'degit'\nimport jsyaml from 'js-yaml'\nimport { FileSystem } from './FileSystem.js'\n\ninterface TemplateInstallerOutput {\n\twarn(message: string): void\n}\n\ntype CloneTemplate = (source: string, target: string) => Promise<void>\n\nconst cloneTemplate: CloneTemplate = async (source, target) => {\n\tconst emitter = degit(source, { cache: false, force: true, verbose: true })\n\tawait emitter.clone(target)\n}\n\nexport class TemplateInstaller {\n\tprivate localTemplates: Record<string, string>\n\n\tconstructor(\n\t\tprivate readonly resourceDir: string,\n\t\tprivate readonly fs: FileSystem,\n\t\tprivate readonly output: TemplateInstallerOutput,\n\t\tprivate readonly clone: CloneTemplate = cloneTemplate,\n\t) {\n\t\tthis.localTemplates = {\n\t\t\t['default']: join(this.resourceDir, 'templates/default'),\n\t\t}\n\t}\n\n\tinstallTemplate = async (\n\t\ttemplate: string,\n\t\ttargetDir: string,\n\t\tvariables: Record<string, string> = {},\n\t) => {\n\t\tlet temporaryTemplateDir: string | undefined\n\t\tlet remoteTemplate: string | undefined\n\n\t\tif (this.localTemplates[template]) {\n\t\t\ttemplate = this.localTemplates[template]\n\t\t} else {\n\t\t\tremoteTemplate = template\n\t\t\ttemporaryTemplateDir = await this.fs.createTempDir()\n\t\t\ttemplate = temporaryTemplateDir\n\t\t}\n\n\t\ttry {\n\t\t\tif (remoteTemplate !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.clone(remoteTemplate, template)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(`Failed to clone template from repository: ${error}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst templateConfigFile = join(template, 'contember.template.yaml')\n\t\t\tif (!(await this.fs.pathExists(templateConfigFile))) {\n\t\t\t\tthrow new Error(`${template} is not a Contember template`)\n\t\t\t}\n\t\t\tconst config = (await this.readYaml(templateConfigFile)) as {\n\t\t\t\ttype?: string\n\t\t\t\tremove?: string[]\n\t\t\t\tpatchPackageJson?: boolean\n\t\t\t\trename?: Record<string, string>\n\t\t\t\tcopy?: Record<string, string>\n\t\t\t\treplaceVariables?: string[]\n\t\t\t}\n\t\t\tconst nodeModulesDir = join(template, 'node_modules')\n\t\t\tconst skippedFiles = new Set([...(config.remove || []).map(it => join(template, it)), templateConfigFile])\n\t\t\tif (await this.fs.pathExists(targetDir)) {\n\t\t\t\tthrow `${targetDir} already exists`\n\t\t\t}\n\t\t\tawait this.fs.copy(template, targetDir, {\n\t\t\t\tfilter: src => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src),\n\t\t\t})\n\n\t\t\tif (config.patchPackageJson) {\n\t\t\t\tawait this.replaceFileContent(join(targetDir, 'package.json'), content => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tversion,\n\t\t\t\t\t\t'scripts-template': scripts,\n\t\t\t\t\t\tscripts: _nullScripts,\n\t\t\t\t\t\tlicense,\n\t\t\t\t\t\t...json\n\t\t\t\t\t} = JSON.parse(content)\n\t\t\t\t\treturn JSON.stringify({ scripts, ...json }, null, ' ')\n\t\t\t\t})\n\t\t\t}\n\t\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\t\tawait this.fs.rename(join(targetDir, source), join(targetDir, target))\n\t\t\t}\n\t\t\tfor (const [source, target] of Object.entries(config.copy || {})) {\n\t\t\t\tawait this.fs.copy(join(targetDir, source), join(targetDir, target))\n\t\t\t}\n\n\t\t\tfor (const file of config.replaceVariables || []) {\n\t\t\t\tconst path = join(targetDir, file)\n\t\t\t\tif (!(await this.fs.pathExists(path))) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tawait this.replaceFileContent(path, content =>\n\t\t\t\t\tObject.entries(variables).reduce(\n\t\t\t\t\t\t(content, [key, value]) => content.replace(new RegExp(`{${key}}`, 'g'), value),\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t))\n\t\t\t}\n\t\t} finally {\n\t\t\tif (temporaryTemplateDir !== undefined) {\n\t\t\t\tawait this.cleanupTemporaryTemplate(temporaryTemplateDir)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate cleanupTemporaryTemplate = async (path: string): Promise<void> => {\n\t\ttry {\n\t\t\tawait this.fs.remove(path, { recursive: true, force: true })\n\t\t} catch {\n\t\t\tthis.output.warn('Failed to clean up the temporary template directory.')\n\t\t}\n\t}\n\n\tprivate replaceFileContent = async (path: string, replacer: (content: string) => string): Promise<void> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\tconst newContent = replacer(content)\n\t\tawait this.fs.writeFile(path, newContent, { encoding: 'utf8' })\n\t}\n\n\tprivate readYaml = async <T = unknown>(path: string): Promise<T> => {\n\t\tconst content = await this.fs.readFile(path, { encoding: 'utf8' })\n\t\treturn jsyaml.load(content) as unknown as T\n\t}\n}\n"],"names":["content","jsyaml"],"mappings":";;;;;;AAWA,MAAM,gBAA+B,OAAO,QAAQ,WAAW;AAC9D,QAAM,UAAU,MAAM,QAAQ,EAAE,OAAO,OAAO,OAAO,MAAM,SAAS,MAAM;AAC1E,QAAM,QAAQ,MAAM,MAAM;AAC3B;AAEO,MAAM,kBAAkB;AAAA,EAG9B,YACkB,aACA,IACA,QACA,QAAuB,eACvC;AAJgB,SAAA,cAAA;AACA,SAAA,KAAA;AACA,SAAA,SAAA;AACA,SAAA,QAAA;AANlB,kBAAA,MAAQ,gBAAA;AAaR,kBAAA,MAAA,mBAAkB,OACjB,UACA,WACA,YAAoC,OAChC;AACJ,UAAI;AACJ,UAAI;AAEJ,UAAI,KAAK,eAAe,QAAQ,GAAG;AAClC,mBAAW,KAAK,eAAe,QAAQ;AAAA,MACxC,OAAO;AACN,yBAAiB;AACjB,+BAAuB,MAAM,KAAK,GAAG,cAAA;AACrC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MAAM,EAAE,UAAU,QAAQ;AACjE,aAAOC,gBAAO,KAAK,OAAO;AAAA,IAC3B,CAAA;AA1GC,SAAK,iBAAiB;AAAA,MACrB,CAAC,SAAS,GAAG,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AAwGD;"}
@@ -1,4 +1,4 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common';
1
+ import { Command, CommandConfiguration, Input, Output } from '@contember/cli-common';
2
2
  import { TemplateInstaller } from '../lib/TemplateInstaller.js';
3
3
  type Args = {
4
4
  projectName: string;
@@ -6,11 +6,23 @@ type Args = {
6
6
  type Options = {
7
7
  template: string;
8
8
  };
9
+ export interface WorkspaceCreateResult {
10
+ projectName: string;
11
+ projectDirectory: string;
12
+ template: string;
13
+ packageManager: string;
14
+ }
15
+ export interface WorkspaceCreateRuntime {
16
+ cwd(): string;
17
+ getPackageVersion(): Promise<string>;
18
+ detectPackageManager(): string;
19
+ }
9
20
  export declare class WorkspaceCreateCommand extends Command<Args, Options> {
10
21
  private readonly templateInstaller;
11
- constructor(templateInstaller: TemplateInstaller);
22
+ private readonly runtime;
23
+ constructor(templateInstaller: Pick<TemplateInstaller, 'installTemplate'>, runtime?: WorkspaceCreateRuntime);
12
24
  protected configure(configuration: CommandConfiguration<Args, Options>): void;
13
- protected execute(input: Input<Args, Options>): Promise<void>;
25
+ protected execute(input: Input<Args, Options>, output: Output): Promise<void>;
14
26
  }
15
27
  export {};
16
28
  //# sourceMappingURL=WorkspaceCreateCommand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkspaceCreateCommand.d.ts","sourceRoot":"","sources":["../../../src/commands/WorkspaceCreateCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAG5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAI/D,KAAK,IAAI,GAAG;IACX,WAAW,E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,CAAC,OAAO;IAFzB,YACkB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAC7D,OAAO,GAAE,sBAAuC,EAGjE;IAED,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,CAI5E;IAED,UAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlF;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/lib/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAItC,qBAAa,UAAU;IACtB,QAAQ,qBAAc;IACtB,SAAS,sBAAe;IACxB,MAAM,mBAAY;IAClB,OAAO,oBAAa;IACpB,IAAI,GAAI,QAAQ,MAAM,EAAE,aAAa,MAAM,EAAE,UAAU;QAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAA;KAAE,mBACxD;IAC5D,MAAM,mBAAY;IAClB,MAAM,eAAQ;IACd,UAAU,GAAU,MAAM,MAAM,sBAO/B;IACD,aAAa,wBAEZ;CACD"}
1
+ {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/lib/FileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAItC,qBAAa,UAAU;IACtB,QAAQ,qBAAc;IACtB,SAAS,sBAAe;IACxB,MAAM,mBAAY;IAClB,OAAO,oBAAa;IACpB,IAAI,WAAY,MAAM,eAAe,MAAM,YAAY;QAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAA;KAAE,mBACxD;IAC5D,MAAM,mBAAY;IAClB,MAAM,eAAQ;IACd,UAAU,SAAgB,MAAM,sBAO/B;IACD,aAAa,wBAEZ;CACD"}
@@ -1,11 +1,19 @@
1
1
  import { FileSystem } from './FileSystem.js';
2
+ interface TemplateInstallerOutput {
3
+ warn(message: string): void;
4
+ }
5
+ type CloneTemplate = (source: string, target: string) => Promise<void>;
2
6
  export declare class TemplateInstaller {
3
7
  private readonly resourceDir;
4
8
  private readonly fs;
9
+ private readonly output;
10
+ private readonly clone;
5
11
  private localTemplates;
6
- constructor(resourceDir: string, fs: FileSystem);
12
+ constructor(resourceDir: string, fs: FileSystem, output: TemplateInstallerOutput, clone?: CloneTemplate);
7
13
  installTemplate: (template: string, targetDir: string, variables?: Record<string, string>) => Promise<void>;
14
+ private cleanupTemporaryTemplate;
8
15
  private replaceFileContent;
9
16
  private readYaml;
10
17
  }
18
+ export {};
11
19
  //# sourceMappingURL=TemplateInstaller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateInstaller.d.ts","sourceRoot":"","sources":["../../../src/lib/TemplateInstaller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,qBAAa,iBAAiB;IAI5B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,EAAE;IAJpB,OAAO,CAAC,cAAc,CAAwB;gBAG5B,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,UAAU;IAOhC,eAAe,GACd,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,YAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,mBAkFtC;IAED,OAAO,CAAC,kBAAkB,CAIzB;IAED,OAAO,CAAC,QAAQ,CAGf;CACD"}
1
+ {"version":3,"file":"TemplateInstaller.d.ts","sourceRoot":"","sources":["../../../src/lib/TemplateInstaller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,C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