@contember/create 2.2.0-alpha.2 → 2.2.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +36 -23
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +37 -24
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +10 -4
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +8 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +71 -60
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +71 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/fsErrors.cjs +7 -0
- package/dist/development/src/lib/fsErrors.cjs.map +1 -0
- package/dist/development/src/lib/fsErrors.js +7 -0
- package/dist/development/src/lib/fsErrors.js.map +1 -0
- package/dist/development/src/lib/projectPath.cjs +66 -0
- package/dist/development/src/lib/projectPath.cjs.map +1 -0
- package/dist/development/src/lib/projectPath.js +66 -0
- package/dist/development/src/lib/projectPath.js.map +1 -0
- package/dist/development/src/lib/remoteTemplate.cjs +108 -0
- package/dist/development/src/lib/remoteTemplate.cjs.map +1 -0
- package/dist/development/src/lib/remoteTemplate.js +108 -0
- package/dist/development/src/lib/remoteTemplate.js.map +1 -0
- package/dist/development/src/lib/tar.cjs +243 -0
- package/dist/development/src/lib/tar.cjs.map +1 -0
- package/dist/development/src/lib/tar.js +243 -0
- package/dist/development/src/lib/tar.js.map +1 -0
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +36 -23
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +37 -24
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +10 -4
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +8 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +71 -60
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +71 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/fsErrors.cjs +7 -0
- package/dist/production/src/lib/fsErrors.cjs.map +1 -0
- package/dist/production/src/lib/fsErrors.js +7 -0
- package/dist/production/src/lib/fsErrors.js.map +1 -0
- package/dist/production/src/lib/projectPath.cjs +66 -0
- package/dist/production/src/lib/projectPath.cjs.map +1 -0
- package/dist/production/src/lib/projectPath.js +66 -0
- package/dist/production/src/lib/projectPath.js.map +1 -0
- package/dist/production/src/lib/remoteTemplate.cjs +108 -0
- package/dist/production/src/lib/remoteTemplate.cjs.map +1 -0
- package/dist/production/src/lib/remoteTemplate.js +108 -0
- package/dist/production/src/lib/remoteTemplate.js.map +1 -0
- package/dist/production/src/lib/tar.cjs +243 -0
- package/dist/production/src/lib/tar.cjs.map +1 -0
- package/dist/production/src/lib/tar.js +243 -0
- package/dist/production/src/lib/tar.js.map +1 -0
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +15 -3
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +2 -0
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +9 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/lib/fsErrors.d.ts +3 -0
- package/dist/types/lib/fsErrors.d.ts.map +1 -0
- package/dist/types/lib/projectPath.d.ts +12 -0
- package/dist/types/lib/projectPath.d.ts.map +1 -0
- package/dist/types/lib/remoteTemplate.d.ts +15 -0
- package/dist/types/lib/remoteTemplate.d.ts.map +1 -0
- package/dist/types/lib/tar.d.ts +28 -0
- package/dist/types/lib/tar.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -7
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-inline-toolbar.tsx +3 -0
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +5 -4
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +453 -4
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +9 -2
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +11 -0
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +42 -4
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +3 -1
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -10
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +160 -22
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +7 -0
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +1 -1
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +20 -11
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +13 -2
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/lib/ui/label.tsx +25 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/progress.tsx +75 -11
- package/resources/templates/default/admin/lib/ui/separator.tsx +27 -3
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle.tsx +41 -2
- package/resources/templates/default/admin/lib/utils/classNames.ts +107 -0
- package/resources/templates/default/admin/lib/utils/cn.ts +3 -3
- package/resources/templates/default/admin/lib/utils/index.ts +1 -0
- package/resources/templates/default/admin/lib/utils/uic.tsx +2 -3
- package/resources/templates/default/admin/package.json +1 -7
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/src/commands/WorkspaceCreateCommand.ts +51 -24
- package/src/lib/FileSystem.ts +7 -2
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/lib/fsErrors.ts +2 -0
- package/src/lib/projectPath.ts +79 -0
- package/src/lib/remoteTemplate.ts +130 -0
- package/src/lib/tar.ts +283 -0
- package/src/run.ts +8 -7
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/fileSystem.test.ts +14 -0
- package/tests/cases/unit/fixtures/template.tar.gz +0 -0
- package/tests/cases/unit/remoteTemplate.test.ts +277 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/template-installer-containment.test.ts +133 -0
- package/tests/cases/unit/template-installer-symlinks.test.ts +37 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -2,80 +2,91 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const jsyaml = require("js-yaml");
|
|
5
|
-
const
|
|
5
|
+
const projectPath = require("./projectPath.cjs");
|
|
6
|
+
const remoteTemplate = require("./remoteTemplate.cjs");
|
|
6
7
|
var __defProp = Object.defineProperty;
|
|
7
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
9
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
+
const cloneTemplate = (source, target) => remoteTemplate.downloadTemplate(source, target);
|
|
9
11
|
class TemplateInstaller {
|
|
10
|
-
constructor(resourceDir, fs) {
|
|
12
|
+
constructor(resourceDir, fs, output, clone = cloneTemplate) {
|
|
11
13
|
this.resourceDir = resourceDir;
|
|
12
14
|
this.fs = fs;
|
|
15
|
+
this.output = output;
|
|
16
|
+
this.clone = clone;
|
|
13
17
|
__publicField(this, "localTemplates");
|
|
14
18
|
__publicField(this, "installTemplate", async (template, targetDir, variables = {}) => {
|
|
15
|
-
let
|
|
16
|
-
|
|
19
|
+
let temporaryTemplateDir;
|
|
20
|
+
let remoteTemplate2;
|
|
17
21
|
if (this.localTemplates[template]) {
|
|
18
22
|
template = this.localTemplates[template];
|
|
19
23
|
} else {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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`);
|
|
24
|
+
remoteTemplate2 = template;
|
|
25
|
+
temporaryTemplateDir = await this.fs.createTempDir();
|
|
26
|
+
template = temporaryTemplateDir;
|
|
40
27
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return JSON.stringify({ scripts, ...json }, null, " ");
|
|
28
|
+
try {
|
|
29
|
+
if (remoteTemplate2 !== void 0) {
|
|
30
|
+
try {
|
|
31
|
+
await this.clone(remoteTemplate2, template);
|
|
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
|
+
throw new Error(`${template} is not a Contember template`);
|
|
39
|
+
}
|
|
40
|
+
const config = await this.readYaml(templateConfigFile);
|
|
41
|
+
const nodeModulesDir = path.join(template, "node_modules");
|
|
42
|
+
const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => path.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)
|
|
62
48
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
if (config.patchPackageJson) {
|
|
50
|
+
await this.replaceFileContent(path.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
|
+
const projectPath$1 = (path2) => projectPath.resolveProjectPath(this.fs, targetDir, path2);
|
|
63
|
+
for (const [source, target] of Object.entries(config.rename || {})) {
|
|
64
|
+
await this.fs.rename(await projectPath$1(source), await projectPath$1(target));
|
|
65
|
+
}
|
|
66
|
+
for (const [source, target] of Object.entries(config.copy || {})) {
|
|
67
|
+
await this.fs.copy(await projectPath$1(source), await projectPath.resolveNewProjectPath(this.fs, targetDir, target));
|
|
68
|
+
}
|
|
69
|
+
for (const file of config.replaceVariables || []) {
|
|
70
|
+
const path2 = await projectPath$1(file);
|
|
71
|
+
if (!await this.fs.pathExists(path2)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
await this.replaceFileContent(path2, (content) => Object.entries(variables).reduce(
|
|
75
|
+
(content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
|
|
76
|
+
content
|
|
77
|
+
));
|
|
74
78
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
} finally {
|
|
80
|
+
if (temporaryTemplateDir !== void 0) {
|
|
81
|
+
await this.cleanupTemporaryTemplate(temporaryTemplateDir);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
__publicField(this, "cleanupTemporaryTemplate", async (path2) => {
|
|
86
|
+
try {
|
|
87
|
+
await this.fs.remove(path2, { recursive: true, force: true });
|
|
88
|
+
} catch {
|
|
89
|
+
this.output.warn("Failed to clean up the temporary template directory.");
|
|
79
90
|
}
|
|
80
91
|
});
|
|
81
92
|
__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
|
|
1
|
+
{"version":3,"file":"TemplateInstaller.cjs","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport jsyaml from 'js-yaml'\nimport { FileSystem } from './FileSystem.js'\nimport { resolveNewProjectPath, resolveProjectPath } from './projectPath.js'\nimport { downloadTemplate } from './remoteTemplate.js'\n\ninterface TemplateInstallerOutput {\n\twarn(message: string): void\n}\n\ntype CloneTemplate = (source: string, target: string) => Promise<void>\n\nconst cloneTemplate: CloneTemplate = (source, target) => downloadTemplate(source, target)\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\t// The template is untrusted input: every directive path must stay inside the new project.\n\t\t\tconst projectPath = (path: string) => resolveProjectPath(this.fs, targetDir, path)\n\t\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\t\tawait this.fs.rename(await projectPath(source), await projectPath(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(await projectPath(source), await resolveNewProjectPath(this.fs, targetDir, target))\n\t\t\t}\n\n\t\t\tfor (const file of config.replaceVariables || []) {\n\t\t\t\tconst path = await projectPath(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":["downloadTemplate","remoteTemplate","join","projectPath","path","resolveProjectPath","resolveNewProjectPath","content"],"mappings":";;;;;;;;;AAYA,MAAM,gBAA+B,CAAC,QAAQ,WAAWA,eAAAA,iBAAiB,QAAQ,MAAM;AAEjF,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,UAAIC;AAEJ,UAAI,KAAK,eAAe,QAAQ,GAAG;AAClC,mBAAW,KAAK,eAAe,QAAQ;AAAA,MACxC,OAAO;AACN,QAAAA,kBAAiB;AACjB,+BAAuB,MAAM,KAAK,GAAG,cAAA;AACrC,mBAAW;AAAA,MACZ;AAEA,UAAI;AACH,YAAIA,oBAAmB,QAAW;AACjC,cAAI;AACH,kBAAM,KAAK,MAAMA,iBAAgB,QAAQ;AAAA,UAC1C,SAAS,OAAO;AACf,kBAAM,IAAI,MAAM,6CAA6C,KAAK,EAAE;AAAA,UACrE;AAAA,QACD;AAEA,cAAM,qBAAqBC,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;AAQtD,cAAM,iBAAiBA,KAAAA,KAAK,UAAU,cAAc;AACpD,cAAM,eAAe,oBAAI,IAAI,CAAC,IAAI,OAAO,UAAU,CAAA,GAAI,IAAI,QAAMA,KAAAA,KAAK,UAAU,EAAE,CAAC,GAAG,kBAAkB,CAAC;AACzG,YAAI,MAAM,KAAK,GAAG,WAAW,SAAS,GAAG;AACxC,gBAAM,GAAG,SAAS;AAAA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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,OAAOH,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;AA5GC,SAAK,iBAAiB;AAAA,MACrB,CAAC,SAAS,GAAGF,KAAAA,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AA0GD;;"}
|
|
@@ -1,79 +1,90 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import jsyaml__default from "js-yaml";
|
|
3
|
-
import
|
|
3
|
+
import { resolveProjectPath, resolveNewProjectPath } from "./projectPath.js";
|
|
4
|
+
import { downloadTemplate } from "./remoteTemplate.js";
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
const cloneTemplate = (source, target) => downloadTemplate(source, target);
|
|
7
9
|
class TemplateInstaller {
|
|
8
|
-
constructor(resourceDir, fs) {
|
|
10
|
+
constructor(resourceDir, fs, output, clone = cloneTemplate) {
|
|
9
11
|
this.resourceDir = resourceDir;
|
|
10
12
|
this.fs = fs;
|
|
13
|
+
this.output = output;
|
|
14
|
+
this.clone = clone;
|
|
11
15
|
__publicField(this, "localTemplates");
|
|
12
16
|
__publicField(this, "installTemplate", async (template, targetDir, variables = {}) => {
|
|
13
|
-
let
|
|
14
|
-
|
|
17
|
+
let temporaryTemplateDir;
|
|
18
|
+
let remoteTemplate;
|
|
15
19
|
if (this.localTemplates[template]) {
|
|
16
20
|
template = this.localTemplates[template];
|
|
17
21
|
} else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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`);
|
|
22
|
+
remoteTemplate = template;
|
|
23
|
+
temporaryTemplateDir = await this.fs.createTempDir();
|
|
24
|
+
template = temporaryTemplateDir;
|
|
38
25
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return JSON.stringify({ scripts, ...json }, null, " ");
|
|
26
|
+
try {
|
|
27
|
+
if (remoteTemplate !== void 0) {
|
|
28
|
+
try {
|
|
29
|
+
await this.clone(remoteTemplate, template);
|
|
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
|
+
throw new Error(`${template} is not a Contember template`);
|
|
37
|
+
}
|
|
38
|
+
const config = await this.readYaml(templateConfigFile);
|
|
39
|
+
const nodeModulesDir = join(template, "node_modules");
|
|
40
|
+
const skippedFiles = /* @__PURE__ */ new Set([...(config.remove || []).map((it) => join(template, it)), templateConfigFile]);
|
|
41
|
+
if (await this.fs.pathExists(targetDir)) {
|
|
42
|
+
throw `${targetDir} already exists`;
|
|
43
|
+
}
|
|
44
|
+
await this.fs.copy(template, targetDir, {
|
|
45
|
+
filter: (src) => !src.startsWith(nodeModulesDir) && !skippedFiles.has(src)
|
|
60
46
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
47
|
+
if (config.patchPackageJson) {
|
|
48
|
+
await this.replaceFileContent(join(targetDir, "package.json"), (content) => {
|
|
49
|
+
const {
|
|
50
|
+
name,
|
|
51
|
+
version,
|
|
52
|
+
"scripts-template": scripts,
|
|
53
|
+
scripts: _nullScripts,
|
|
54
|
+
license,
|
|
55
|
+
...json
|
|
56
|
+
} = JSON.parse(content);
|
|
57
|
+
return JSON.stringify({ scripts, ...json }, null, " ");
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const projectPath = (path) => resolveProjectPath(this.fs, targetDir, path);
|
|
61
|
+
for (const [source, target] of Object.entries(config.rename || {})) {
|
|
62
|
+
await this.fs.rename(await projectPath(source), await projectPath(target));
|
|
63
|
+
}
|
|
64
|
+
for (const [source, target] of Object.entries(config.copy || {})) {
|
|
65
|
+
await this.fs.copy(await projectPath(source), await resolveNewProjectPath(this.fs, targetDir, target));
|
|
66
|
+
}
|
|
67
|
+
for (const file of config.replaceVariables || []) {
|
|
68
|
+
const path = await projectPath(file);
|
|
69
|
+
if (!await this.fs.pathExists(path)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
await this.replaceFileContent(path, (content) => Object.entries(variables).reduce(
|
|
73
|
+
(content2, [key, value]) => content2.replace(new RegExp(`{${key}}`, "g"), value),
|
|
74
|
+
content
|
|
75
|
+
));
|
|
72
76
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
} finally {
|
|
78
|
+
if (temporaryTemplateDir !== void 0) {
|
|
79
|
+
await this.cleanupTemporaryTemplate(temporaryTemplateDir);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
__publicField(this, "cleanupTemporaryTemplate", async (path) => {
|
|
84
|
+
try {
|
|
85
|
+
await this.fs.remove(path, { recursive: true, force: true });
|
|
86
|
+
} catch {
|
|
87
|
+
this.output.warn("Failed to clean up the temporary template directory.");
|
|
77
88
|
}
|
|
78
89
|
});
|
|
79
90
|
__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
|
|
1
|
+
{"version":3,"file":"TemplateInstaller.js","sources":["../../../../../packages/create/src/lib/TemplateInstaller.ts"],"sourcesContent":["import { join } from 'node:path'\nimport jsyaml from 'js-yaml'\nimport { FileSystem } from './FileSystem.js'\nimport { resolveNewProjectPath, resolveProjectPath } from './projectPath.js'\nimport { downloadTemplate } from './remoteTemplate.js'\n\ninterface TemplateInstallerOutput {\n\twarn(message: string): void\n}\n\ntype CloneTemplate = (source: string, target: string) => Promise<void>\n\nconst cloneTemplate: CloneTemplate = (source, target) => downloadTemplate(source, target)\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\t// The template is untrusted input: every directive path must stay inside the new project.\n\t\t\tconst projectPath = (path: string) => resolveProjectPath(this.fs, targetDir, path)\n\t\t\tfor (const [source, target] of Object.entries(config.rename || {})) {\n\t\t\t\tawait this.fs.rename(await projectPath(source), await projectPath(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(await projectPath(source), await resolveNewProjectPath(this.fs, targetDir, target))\n\t\t\t}\n\n\t\t\tfor (const file of config.replaceVariables || []) {\n\t\t\t\tconst path = await projectPath(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":";;;;;;;AAYA,MAAM,gBAA+B,CAAC,QAAQ,WAAW,iBAAiB,QAAQ,MAAM;AAEjF,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,Q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,QAAQ;AACjE,aAAOC,gBAAO,KAAK,OAAO;AAAA,IAC3B,CAAA;AA5GC,SAAK,iBAAiB;AAAA,MACrB,CAAC,SAAS,GAAG,KAAK,KAAK,aAAa,mBAAmB;AAAA,IAAA;AAAA,EAEzD;AA0GD;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const hasCode = (error, code) => error instanceof Error && "code" in error && error.code === code;
|
|
4
|
+
const isNotFound = (error) => hasCode(error, "ENOENT");
|
|
5
|
+
exports.hasCode = hasCode;
|
|
6
|
+
exports.isNotFound = isNotFound;
|
|
7
|
+
//# sourceMappingURL=fsErrors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsErrors.cjs","sources":["../../../../../packages/create/src/lib/fsErrors.ts"],"sourcesContent":["export const hasCode = (error: unknown, code: string): boolean => error instanceof Error && 'code' in error && error.code === code\nexport const isNotFound = (error: unknown): boolean => hasCode(error, 'ENOENT')\n"],"names":[],"mappings":";;AAAO,MAAM,UAAU,CAAC,OAAgB,SAA0B,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS;AACvH,MAAM,aAAa,CAAC,UAA4B,QAAQ,OAAO,QAAQ;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsErrors.js","sources":["../../../../../packages/create/src/lib/fsErrors.ts"],"sourcesContent":["export const hasCode = (error: unknown, code: string): boolean => error instanceof Error && 'code' in error && error.code === code\nexport const isNotFound = (error: unknown): boolean => hasCode(error, 'ENOENT')\n"],"names":[],"mappings":"AAAO,MAAM,UAAU,CAAC,OAAgB,SAA0B,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS;AACvH,MAAM,aAAa,CAAC,UAA4B,QAAQ,OAAO,QAAQ;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const fsErrors = require("./fsErrors.cjs");
|
|
5
|
+
const resolveProjectPath = async (fs, root, path$1) => {
|
|
6
|
+
const outside = new Error(`Template path "${path$1}" points outside the project`);
|
|
7
|
+
if (path.isAbsolute(path$1)) {
|
|
8
|
+
throw outside;
|
|
9
|
+
}
|
|
10
|
+
const resolved = path.resolve(root, path$1);
|
|
11
|
+
if (!isStrictlyInside(root, resolved)) {
|
|
12
|
+
throw outside;
|
|
13
|
+
}
|
|
14
|
+
const realRoot = await fs.realPath(root);
|
|
15
|
+
const realPath = await resolveExistingPrefix(fs, resolved);
|
|
16
|
+
if (realPath === void 0) {
|
|
17
|
+
throw new Error(`Template path "${path$1}" passes through a dangling symlink`);
|
|
18
|
+
}
|
|
19
|
+
if (!isStrictlyInside(realRoot, realPath)) {
|
|
20
|
+
throw outside;
|
|
21
|
+
}
|
|
22
|
+
return resolved;
|
|
23
|
+
};
|
|
24
|
+
const resolveNewProjectPath = async (fs, root, path2) => {
|
|
25
|
+
const resolved = await resolveProjectPath(fs, root, path2);
|
|
26
|
+
if (await isPresent(fs, resolved)) {
|
|
27
|
+
throw new Error(`Template path "${path2}" already exists`);
|
|
28
|
+
}
|
|
29
|
+
return resolved;
|
|
30
|
+
};
|
|
31
|
+
const isStrictlyInside = (root, path$1) => {
|
|
32
|
+
const rel = path.relative(root, path$1);
|
|
33
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel);
|
|
34
|
+
};
|
|
35
|
+
const resolveExistingPrefix = async (fs, path$1) => {
|
|
36
|
+
try {
|
|
37
|
+
return await fs.realPath(path$1);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (!fsErrors.isNotFound(error)) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (await isPresent(fs, path$1)) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
const parent = path.dirname(path$1);
|
|
47
|
+
if (parent === path$1) {
|
|
48
|
+
return path$1;
|
|
49
|
+
}
|
|
50
|
+
const realParent = await resolveExistingPrefix(fs, parent);
|
|
51
|
+
return realParent === void 0 ? void 0 : path.join(realParent, path.basename(path$1));
|
|
52
|
+
};
|
|
53
|
+
const isPresent = async (fs, path2) => {
|
|
54
|
+
try {
|
|
55
|
+
await fs.lstat(path2);
|
|
56
|
+
return true;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (fsErrors.isNotFound(error)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.resolveNewProjectPath = resolveNewProjectPath;
|
|
65
|
+
exports.resolveProjectPath = resolveProjectPath;
|
|
66
|
+
//# sourceMappingURL=projectPath.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectPath.cjs","sources":["../../../../../packages/create/src/lib/projectPath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { FileSystem } from './FileSystem.js'\nimport { isNotFound } from './fsErrors.js'\n\n/**\n * Resolves a path from a template directive against the project root.\n * Refuses absolute paths, the root itself and anything that leaves the root, lexically or through a symlink.\n */\nexport const resolveProjectPath = async (fs: FileSystem, root: string, path: string): Promise<string> => {\n\tconst outside = new Error(`Template path \"${path}\" points outside the project`)\n\tif (isAbsolute(path)) {\n\t\tthrow outside\n\t}\n\tconst resolved = resolve(root, path)\n\tif (!isStrictlyInside(root, resolved)) {\n\t\tthrow outside\n\t}\n\tconst realRoot = await fs.realPath(root)\n\tconst realPath = await resolveExistingPrefix(fs, resolved)\n\tif (realPath === undefined) {\n\t\tthrow new Error(`Template path \"${path}\" passes through a dangling symlink`)\n\t}\n\tif (!isStrictlyInside(realRoot, realPath)) {\n\t\tthrow outside\n\t}\n\treturn resolved\n}\n\n/**\n * Like resolveProjectPath, and the path must not exist yet. fs.cp into an existing directory writes entries the check\n * above never saw, and Bun's fs.cp follows symlinks it finds there.\n */\nexport const resolveNewProjectPath = async (fs: FileSystem, root: string, path: string): Promise<string> => {\n\tconst resolved = await resolveProjectPath(fs, root, path)\n\tif (await isPresent(fs, resolved)) {\n\t\tthrow new Error(`Template path \"${path}\" already exists`)\n\t}\n\treturn resolved\n}\n\nconst isStrictlyInside = (root: string, path: string): boolean => {\n\tconst rel = relative(root, path)\n\treturn rel !== '' && rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)\n}\n\n/**\n * realpath() of the longest existing prefix, with the missing components appended (they cannot be symlinks).\n * Returns undefined for a dangling symlink: writing to it would create its target, wherever that is.\n */\nconst resolveExistingPrefix = async (fs: FileSystem, path: string): Promise<string | undefined> => {\n\ttry {\n\t\treturn await fs.realPath(path)\n\t} catch (error) {\n\t\tif (!isNotFound(error)) {\n\t\t\tthrow error\n\t\t}\n\t}\n\tif (await isPresent(fs, path)) {\n\t\treturn undefined\n\t}\n\tconst parent = dirname(path)\n\tif (parent === path) {\n\t\treturn path\n\t}\n\tconst realParent = await resolveExistingPrefix(fs, parent)\n\treturn realParent === undefined ? undefined : join(realParent, basename(path))\n}\n\nconst isPresent = async (fs: FileSystem, path: string): Promise<boolean> => {\n\ttry {\n\t\tawait fs.lstat(path)\n\t\treturn true\n\t} catch (error) {\n\t\tif (isNotFound(error)) {\n\t\t\treturn false\n\t\t}\n\t\tthrow error\n\t}\n}\n"],"names":["path","isAbsolute","resolve","relative","sep","isNotFound","dirname","join","basename"],"mappings":";;;;AAQO,MAAM,qBAAqB,OAAO,IAAgB,MAAcA,WAAkC;AACxG,QAAM,UAAU,IAAI,MAAM,kBAAkBA,MAAI,8BAA8B;AAC9E,MAAIC,KAAAA,WAAWD,MAAI,GAAG;AACrB,UAAM;AAAA,EACP;AACA,QAAM,WAAWE,KAAAA,QAAQ,MAAMF,MAAI;AACnC,MAAI,CAAC,iBAAiB,MAAM,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mC;AAC3E,MAAI;AACH,UAAM,GAAG,MAAMA,KAAI;AACnB,WAAO;AAAA,EACR,SAAS,OAAO;AACf,QAAIK,SAAAA,WAAW,KAAK,GAAG;AACtB,aAAO;AAAA,IACR;AACA,UAAM;AAAA,EACP;AACD;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isAbsolute, resolve, relative, sep, dirname, join, basename } from "node:path";
|
|
2
|
+
import { isNotFound } from "./fsErrors.js";
|
|
3
|
+
const resolveProjectPath = async (fs, root, path) => {
|
|
4
|
+
const outside = new Error(`Template path "${path}" points outside the project`);
|
|
5
|
+
if (isAbsolute(path)) {
|
|
6
|
+
throw outside;
|
|
7
|
+
}
|
|
8
|
+
const resolved = resolve(root, path);
|
|
9
|
+
if (!isStrictlyInside(root, resolved)) {
|
|
10
|
+
throw outside;
|
|
11
|
+
}
|
|
12
|
+
const realRoot = await fs.realPath(root);
|
|
13
|
+
const realPath = await resolveExistingPrefix(fs, resolved);
|
|
14
|
+
if (realPath === void 0) {
|
|
15
|
+
throw new Error(`Template path "${path}" passes through a dangling symlink`);
|
|
16
|
+
}
|
|
17
|
+
if (!isStrictlyInside(realRoot, realPath)) {
|
|
18
|
+
throw outside;
|
|
19
|
+
}
|
|
20
|
+
return resolved;
|
|
21
|
+
};
|
|
22
|
+
const resolveNewProjectPath = async (fs, root, path) => {
|
|
23
|
+
const resolved = await resolveProjectPath(fs, root, path);
|
|
24
|
+
if (await isPresent(fs, resolved)) {
|
|
25
|
+
throw new Error(`Template path "${path}" already exists`);
|
|
26
|
+
}
|
|
27
|
+
return resolved;
|
|
28
|
+
};
|
|
29
|
+
const isStrictlyInside = (root, path) => {
|
|
30
|
+
const rel = relative(root, path);
|
|
31
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
32
|
+
};
|
|
33
|
+
const resolveExistingPrefix = async (fs, path) => {
|
|
34
|
+
try {
|
|
35
|
+
return await fs.realPath(path);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (!isNotFound(error)) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (await isPresent(fs, path)) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
const parent = dirname(path);
|
|
45
|
+
if (parent === path) {
|
|
46
|
+
return path;
|
|
47
|
+
}
|
|
48
|
+
const realParent = await resolveExistingPrefix(fs, parent);
|
|
49
|
+
return realParent === void 0 ? void 0 : join(realParent, basename(path));
|
|
50
|
+
};
|
|
51
|
+
const isPresent = async (fs, path) => {
|
|
52
|
+
try {
|
|
53
|
+
await fs.lstat(path);
|
|
54
|
+
return true;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (isNotFound(error)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
resolveNewProjectPath,
|
|
64
|
+
resolveProjectPath
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=projectPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectPath.js","sources":["../../../../../packages/create/src/lib/projectPath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { FileSystem } from './FileSystem.js'\nimport { isNotFound } from './fsErrors.js'\n\n/**\n * Resolves a path from a template directive against the project root.\n * Refuses absolute paths, the root itself and anything that leaves the root, lexically or through a symlink.\n */\nexport const resolveProjectPath = async (fs: FileSystem, root: string, path: string): Promise<string> => {\n\tconst outside = new Error(`Template path \"${path}\" points outside the project`)\n\tif (isAbsolute(path)) {\n\t\tthrow outside\n\t}\n\tconst resolved = resolve(root, path)\n\tif (!isStrictlyInside(root, resolved)) {\n\t\tthrow outside\n\t}\n\tconst realRoot = await fs.realPath(root)\n\tconst realPath = await resolveExistingPrefix(fs, resolved)\n\tif (realPath === undefined) {\n\t\tthrow new Error(`Template path \"${path}\" passes through a dangling symlink`)\n\t}\n\tif (!isStrictlyInside(realRoot, realPath)) {\n\t\tthrow outside\n\t}\n\treturn resolved\n}\n\n/**\n * Like resolveProjectPath, and the path must not exist yet. fs.cp into an existing directory writes entries the check\n * above never saw, and Bun's fs.cp follows symlinks it finds there.\n */\nexport const resolveNewProjectPath = async (fs: FileSystem, root: string, path: string): Promise<string> => {\n\tconst resolved = await resolveProjectPath(fs, root, path)\n\tif (await isPresent(fs, resolved)) {\n\t\tthrow new Error(`Template path \"${path}\" already exists`)\n\t}\n\treturn resolved\n}\n\nconst isStrictlyInside = (root: string, path: string): boolean => {\n\tconst rel = relative(root, path)\n\treturn rel !== '' && rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)\n}\n\n/**\n * realpath() of the longest existing prefix, with the missing components appended (they cannot be symlinks).\n * Returns undefined for a dangling symlink: writing to it would create its target, wherever that is.\n */\nconst resolveExistingPrefix = async (fs: FileSystem, path: string): Promise<string | undefined> => {\n\ttry {\n\t\treturn await fs.realPath(path)\n\t} catch (error) {\n\t\tif (!isNotFound(error)) {\n\t\t\tthrow error\n\t\t}\n\t}\n\tif (await isPresent(fs, path)) {\n\t\treturn undefined\n\t}\n\tconst parent = dirname(path)\n\tif (parent === path) {\n\t\treturn path\n\t}\n\tconst realParent = await resolveExistingPrefix(fs, parent)\n\treturn realParent === undefined ? undefined : join(realParent, basename(path))\n}\n\nconst isPresent = async (fs: FileSystem, path: string): Promise<boolean> => {\n\ttry {\n\t\tawait fs.lstat(path)\n\t\treturn true\n\t} catch (error) {\n\t\tif (isNotFound(error)) {\n\t\t\treturn false\n\t\t}\n\t\tthrow error\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,qBAAqB,OAAO,IAAgB,MAAc,SAAkC;AACxG,QAAM,UAAU,IAAI,MAAM,kBAAkB,IAAI,8BAA8B;AAC9E,MAAI,WAAW,IAAI,GAAG;AACrB,UAAM;AAAA,EACP;AACA,QAAM,WAAW,Q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