create-qpq-app 0.1.11 → 0.1.13
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/lib/commonjs/cli/runCreateQpqApp.js +14 -12
- package/lib/commonjs/cli/runCreateQpqApp.js.map +1 -1
- package/lib/commonjs/lib/getArgValue.d.ts +1 -0
- package/lib/commonjs/lib/getArgValue.js +14 -0
- package/lib/commonjs/lib/getArgValue.js.map +1 -0
- package/lib/commonjs/lib/{packageRoot.d.ts → getOwnPackageRoot.d.ts} +0 -1
- package/lib/commonjs/lib/{packageRoot.js → getOwnPackageRoot.js} +2 -7
- package/lib/commonjs/lib/getOwnPackageRoot.js.map +1 -0
- package/lib/commonjs/lib/getOwnVersion.d.ts +1 -0
- package/lib/commonjs/lib/getOwnVersion.js +15 -0
- package/lib/commonjs/lib/getOwnVersion.js.map +1 -0
- package/lib/commonjs/lib/{args.d.ts → getPositionalArgs.d.ts} +0 -1
- package/lib/commonjs/lib/getPositionalArgs.js +12 -0
- package/lib/commonjs/lib/getPositionalArgs.js.map +1 -0
- package/lib/commonjs/lib/index.d.ts +11 -0
- package/lib/commonjs/lib/index.js +28 -0
- package/lib/commonjs/lib/index.js.map +1 -0
- package/lib/commonjs/lib/listFilesRecursive.d.ts +1 -0
- package/lib/commonjs/lib/listFilesRecursive.js +27 -0
- package/lib/commonjs/lib/listFilesRecursive.js.map +1 -0
- package/lib/commonjs/lib/{prompts.js → promptSelect.js} +1 -1
- package/lib/commonjs/lib/promptSelect.js.map +1 -0
- package/lib/commonjs/lib/readJsonFile.d.ts +1 -0
- package/lib/commonjs/lib/readJsonFile.js +13 -0
- package/lib/commonjs/lib/readJsonFile.js.map +1 -0
- package/lib/commonjs/lib/replaceInFileExact.d.ts +1 -0
- package/lib/commonjs/lib/replaceInFileExact.js +18 -0
- package/lib/commonjs/lib/replaceInFileExact.js.map +1 -0
- package/lib/commonjs/lib/replaceInFiles.d.ts +1 -0
- package/lib/commonjs/lib/replaceInFiles.js +32 -0
- package/lib/commonjs/lib/replaceInFiles.js.map +1 -0
- package/lib/commonjs/lib/writeJsonFile.d.ts +1 -0
- package/lib/commonjs/lib/writeJsonFile.js +12 -0
- package/lib/commonjs/lib/writeJsonFile.js.map +1 -0
- package/lib/commonjs/steps/001_preflight.js +3 -3
- package/lib/commonjs/steps/001_preflight.js.map +1 -1
- package/lib/commonjs/steps/002_copyTemplate.js +1 -1
- package/lib/commonjs/steps/002_copyTemplate.js.map +1 -1
- package/lib/commonjs/steps/003_deleteDocusaurus.js +5 -4
- package/lib/commonjs/steps/003_deleteDocusaurus.js.map +1 -1
- package/lib/commonjs/steps/005_applyAppIdentity.js +12 -9
- package/lib/commonjs/steps/005_applyAppIdentity.js.map +1 -1
- package/lib/commonjs/steps/006_applyDomain.js +6 -4
- package/lib/commonjs/steps/006_applyDomain.js.map +1 -1
- package/lib/commonjs/steps/007_pinRegistryVersions.js +5 -4
- package/lib/commonjs/steps/007_pinRegistryVersions.js.map +1 -1
- package/lib/commonjs/steps/008_transpileToJavaScript.js +19 -17
- package/lib/commonjs/steps/008_transpileToJavaScript.js.map +1 -1
- package/lib/commonjs/steps/009_restoreGitignore.js +2 -2
- package/lib/commonjs/steps/009_restoreGitignore.js.map +1 -1
- package/lib/commonjs/steps/010_gitInit.js +1 -1
- package/lib/commonjs/steps/010_gitInit.js.map +1 -1
- package/lib/commonjs/steps/013_printNextSteps.js +1 -1
- package/lib/commonjs/steps/013_printNextSteps.js.map +1 -1
- package/lib/commonjs/steps/index.js +1 -1
- package/lib/commonjs/steps/index.js.map +1 -1
- package/lib/commonjs/types/AppLanguage.d.ts +4 -0
- package/lib/commonjs/{types.js → types/AppLanguage.js} +1 -1
- package/lib/commonjs/types/AppLanguage.js.map +1 -0
- package/lib/commonjs/types/CreateQpqAppAnswers.d.ts +8 -0
- package/lib/commonjs/types/CreateQpqAppAnswers.js +3 -0
- package/lib/commonjs/types/CreateQpqAppAnswers.js.map +1 -0
- package/lib/commonjs/types/CreateQpqAppStep.d.ts +7 -0
- package/lib/commonjs/types/CreateQpqAppStep.js +3 -0
- package/lib/commonjs/types/CreateQpqAppStep.js.map +1 -0
- package/lib/commonjs/types/StepContext.d.ts +7 -0
- package/lib/commonjs/types/StepContext.js +3 -0
- package/lib/commonjs/types/StepContext.js.map +1 -0
- package/lib/commonjs/types/index.d.ts +4 -0
- package/lib/commonjs/types/index.js +21 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/esm/cli/runCreateQpqApp.js +8 -6
- package/lib/esm/cli/runCreateQpqApp.js.map +1 -1
- package/lib/esm/lib/getArgValue.d.ts +1 -0
- package/lib/esm/lib/getArgValue.js +10 -0
- package/lib/esm/lib/getArgValue.js.map +1 -0
- package/lib/esm/lib/{packageRoot.d.ts → getOwnPackageRoot.d.ts} +0 -1
- package/lib/esm/lib/{packageRoot.js → getOwnPackageRoot.js} +1 -5
- package/lib/esm/lib/getOwnPackageRoot.js.map +1 -0
- package/lib/esm/lib/getOwnVersion.d.ts +1 -0
- package/lib/esm/lib/getOwnVersion.js +8 -0
- package/lib/esm/lib/getOwnVersion.js.map +1 -0
- package/lib/esm/lib/{args.d.ts → getPositionalArgs.d.ts} +0 -1
- package/lib/esm/lib/getPositionalArgs.js +8 -0
- package/lib/esm/lib/getPositionalArgs.js.map +1 -0
- package/lib/esm/lib/index.d.ts +11 -0
- package/lib/esm/lib/index.js +12 -0
- package/lib/esm/lib/index.js.map +1 -0
- package/lib/esm/lib/listFilesRecursive.d.ts +1 -0
- package/lib/esm/lib/listFilesRecursive.js +20 -0
- package/lib/esm/lib/listFilesRecursive.js.map +1 -0
- package/lib/esm/lib/{prompts.js → promptSelect.js} +1 -1
- package/lib/esm/lib/promptSelect.js.map +1 -0
- package/lib/esm/lib/readJsonFile.d.ts +1 -0
- package/lib/esm/lib/readJsonFile.js +6 -0
- package/lib/esm/lib/readJsonFile.js.map +1 -0
- package/lib/esm/lib/replaceInFileExact.d.ts +1 -0
- package/lib/esm/lib/replaceInFileExact.js +11 -0
- package/lib/esm/lib/replaceInFileExact.js.map +1 -0
- package/lib/esm/lib/replaceInFiles.d.ts +1 -0
- package/lib/esm/lib/replaceInFiles.js +25 -0
- package/lib/esm/lib/replaceInFiles.js.map +1 -0
- package/lib/esm/lib/writeJsonFile.d.ts +1 -0
- package/lib/esm/lib/writeJsonFile.js +5 -0
- package/lib/esm/lib/writeJsonFile.js.map +1 -0
- package/lib/esm/steps/001_preflight.js +3 -3
- package/lib/esm/steps/001_preflight.js.map +1 -1
- package/lib/esm/steps/002_copyTemplate.js +1 -1
- package/lib/esm/steps/002_copyTemplate.js.map +1 -1
- package/lib/esm/steps/003_deleteDocusaurus.js +3 -2
- package/lib/esm/steps/003_deleteDocusaurus.js.map +1 -1
- package/lib/esm/steps/005_applyAppIdentity.js +6 -3
- package/lib/esm/steps/005_applyAppIdentity.js.map +1 -1
- package/lib/esm/steps/006_applyDomain.js +3 -1
- package/lib/esm/steps/006_applyDomain.js.map +1 -1
- package/lib/esm/steps/007_pinRegistryVersions.js +3 -2
- package/lib/esm/steps/007_pinRegistryVersions.js.map +1 -1
- package/lib/esm/steps/008_transpileToJavaScript.js +10 -8
- package/lib/esm/steps/008_transpileToJavaScript.js.map +1 -1
- package/lib/esm/steps/009_restoreGitignore.js +1 -1
- package/lib/esm/steps/009_restoreGitignore.js.map +1 -1
- package/lib/esm/steps/010_gitInit.js +1 -1
- package/lib/esm/steps/010_gitInit.js.map +1 -1
- package/lib/esm/steps/013_printNextSteps.js +1 -1
- package/lib/esm/steps/013_printNextSteps.js.map +1 -1
- package/lib/esm/steps/index.js +1 -1
- package/lib/esm/steps/index.js.map +1 -1
- package/lib/esm/types/AppLanguage.d.ts +4 -0
- package/lib/esm/{types.js → types/AppLanguage.js} +1 -1
- package/lib/esm/types/AppLanguage.js.map +1 -0
- package/lib/esm/types/CreateQpqAppAnswers.d.ts +8 -0
- package/lib/esm/types/CreateQpqAppAnswers.js +2 -0
- package/lib/esm/types/CreateQpqAppAnswers.js.map +1 -0
- package/lib/esm/types/CreateQpqAppStep.d.ts +7 -0
- package/lib/esm/types/CreateQpqAppStep.js +2 -0
- package/lib/esm/types/CreateQpqAppStep.js.map +1 -0
- package/lib/esm/types/StepContext.d.ts +7 -0
- package/lib/esm/types/StepContext.js +2 -0
- package/lib/esm/types/StepContext.js.map +1 -0
- package/lib/esm/types/index.d.ts +4 -0
- package/lib/esm/types/index.js +5 -0
- package/lib/esm/types/index.js.map +1 -0
- package/package.json +5 -4
- package/template/docusaurus/docs/actions/core/crypto/_category_.json +7 -0
- package/template/docusaurus/docs/actions/core/crypto/ask-crypto-decrypt.md +61 -0
- package/template/docusaurus/docs/actions/core/crypto/ask-crypto-encrypt.md +66 -0
- package/template/docusaurus/docs/actions/core/key-value-store/ask-key-value-store-scan-all-scopes.md +98 -0
- package/template/docusaurus/docs/actions/features/_category_.json +1 -1
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-append-server-event.md +2 -2
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-create.md +2 -2
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-event-append.md +17 -15
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-event-list.md +9 -9
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-event-write.md +7 -7
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-get-by-id.md +5 -5
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-get-draft.md +4 -4
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-provide-store.md +6 -0
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-references.md +47 -0
- package/template/docusaurus/docs/actions/features/event-doc/ask-event-doc-soft-delete.md +48 -10
- package/template/docusaurus/docs/actions/features/event-doc-transfer/_category_.json +1 -0
- package/template/docusaurus/docs/actions/features/event-doc-transfer/ask-event-doc-bundle-apply.md +67 -0
- package/template/docusaurus/docs/actions/features/event-doc-transfer/ask-event-doc-bundle-plan.md +67 -0
- package/template/docusaurus/docs/actions/features/event-doc-transfer/ask-event-doc-manifest.md +64 -0
- package/template/docusaurus/docs/actions/features/event-doc-transfer/ask-event-doc-transfer-export.md +67 -0
- package/template/docusaurus/docs/actions/xstate/ask-state-machine-send-event.md +6 -6
- package/template/docusaurus/docs/config/core/crypto-key.md +53 -0
- package/template/docusaurus/docs/config/core/key-value-store.md +53 -1
- package/template/docusaurus/docs/config/features/event-doc-routes.md +5 -1
- package/template/docusaurus/docs/config/features/event-doc-summary.md +7 -6
- package/template/docusaurus/docs/config/features/event-doc-transfer.md +81 -0
- package/template/docusaurus/docs/config/features/event-doc.md +1 -0
- package/template/docusaurus/docs/config/features/tenanted-event-doc-transfer.md +59 -0
- package/template/docusaurus/docs/config/features/tenanted-event-doc.md +1 -0
- package/template/docusaurus/docs/config/webserver/migration.md +4 -0
- package/template/package.json +1 -0
- package/lib/commonjs/lib/args.js +0 -21
- package/lib/commonjs/lib/args.js.map +0 -1
- package/lib/commonjs/lib/files.d.ts +0 -5
- package/lib/commonjs/lib/files.js +0 -65
- package/lib/commonjs/lib/files.js.map +0 -1
- package/lib/commonjs/lib/packageRoot.js.map +0 -1
- package/lib/commonjs/lib/prompts.js.map +0 -1
- package/lib/commonjs/types.d.ts +0 -22
- package/lib/commonjs/types.js.map +0 -1
- package/lib/esm/lib/args.js +0 -16
- package/lib/esm/lib/args.js.map +0 -1
- package/lib/esm/lib/files.d.ts +0 -5
- package/lib/esm/lib/files.js +0 -54
- package/lib/esm/lib/files.js.map +0 -1
- package/lib/esm/lib/packageRoot.js.map +0 -1
- package/lib/esm/lib/prompts.js.map +0 -1
- package/lib/esm/types.d.ts +0 -22
- package/lib/esm/types.js.map +0 -1
- /package/lib/commonjs/lib/{prompts.d.ts → promptSelect.d.ts} +0 -0
- /package/lib/esm/lib/{prompts.d.ts → promptSelect.d.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './getArgValue';
|
|
2
|
+
export * from './getOwnPackageRoot';
|
|
3
|
+
export * from './getOwnVersion';
|
|
4
|
+
export * from './getPositionalArgs';
|
|
5
|
+
export * from './listFilesRecursive';
|
|
6
|
+
export * from './promptSelect';
|
|
7
|
+
export * from './readJsonFile';
|
|
8
|
+
export * from './replaceInFileExact';
|
|
9
|
+
export * from './replaceInFiles';
|
|
10
|
+
export * from './runCommand';
|
|
11
|
+
export * from './writeJsonFile';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './getArgValue';\nexport * from './getOwnPackageRoot';\nexport * from './getOwnVersion';\nexport * from './getPositionalArgs';\nexport * from './listFilesRecursive';\nexport * from './promptSelect';\nexport * from './readJsonFile';\nexport * from './replaceInFileExact';\nexport * from './replaceInFiles';\nexport * from './runCommand';\nexport * from './writeJsonFile';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const listFilesRecursive: (root: string) => string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// Depth-first list of every file under root (root must exist).
|
|
4
|
+
export const listFilesRecursive = (root) => {
|
|
5
|
+
const files = [];
|
|
6
|
+
const walk = (dir) => {
|
|
7
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
8
|
+
const fullPath = path.join(dir, entry.name);
|
|
9
|
+
if (entry.isDirectory()) {
|
|
10
|
+
walk(fullPath);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
files.push(fullPath);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
walk(root);
|
|
18
|
+
return files;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=listFilesRecursive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listFilesRecursive.js","sourceRoot":"","sources":["../../../src/lib/listFilesRecursive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAY,EAAE;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,MAAM,IAAI,GAAG,CAAC,GAAW,EAAQ,EAAE;QACjC,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\n// Depth-first list of every file under root (root must exist).\nexport const listFilesRecursive = (root: string): string[] => {\n const files: string[] = [];\n\n const walk = (dir: string): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n walk(fullPath);\n } else {\n files.push(fullPath);\n }\n }\n };\n\n walk(root);\n return files;\n};\n"]}
|
|
@@ -4,4 +4,4 @@ export const promptSelect = async (message, choices, defaultChoice) => {
|
|
|
4
4
|
const { select } = await import('@inquirer/prompts');
|
|
5
5
|
return select({ message, choices, default: defaultChoice });
|
|
6
6
|
};
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=promptSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptSelect.js","sourceRoot":"","sources":["../../../src/lib/promptSelect.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAAe,EAAE,OAAiB,EAAE,aAAsB,EAAmB,EAAE;IAChH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["// Present a single-choice list prompt and return the selected value.\n// @inquirer/prompts is imported lazily so fully-flagged runs never pay for it.\nexport const promptSelect = async (message: string, choices: string[], defaultChoice?: string): Promise<string> => {\n const { select } = await import('@inquirer/prompts');\n return select({ message, choices, default: defaultChoice });\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readJsonFile: <T = any>(filePath: string) => T;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
// Default is any (not unknown) because every caller mutates loosely-shaped
|
|
3
|
+
// JSON (package.json, deploy configs) in place; forcing casts at each call
|
|
4
|
+
// site would add noise without safety.
|
|
5
|
+
export const readJsonFile = (filePath) => JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
6
|
+
//# sourceMappingURL=readJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readJsonFile.js","sourceRoot":"","sources":["../../../src/lib/readJsonFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,2EAA2E;AAC3E,2EAA2E;AAC3E,uCAAuC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAU,QAAgB,EAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import fs from 'fs';\n\n// Default is any (not unknown) because every caller mutates loosely-shaped\n// JSON (package.json, deploy configs) in place; forcing casts at each call\n// site would add noise without safety.\nexport const readJsonFile = <T = any>(filePath: string): T => JSON.parse(fs.readFileSync(filePath, 'utf8'));\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const replaceInFileExact: (filePath: string, from: string, to: string) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
// Replace an exact string in one file, throwing if it isn't there. Targeted
|
|
3
|
+
// edits should fail loudly when the template drifts.
|
|
4
|
+
export const replaceInFileExact = (filePath, from, to) => {
|
|
5
|
+
const original = fs.readFileSync(filePath, 'utf8');
|
|
6
|
+
if (!original.includes(from)) {
|
|
7
|
+
throw new Error(`Expected to find "${from}" in ${filePath}. Has the template changed?`);
|
|
8
|
+
}
|
|
9
|
+
fs.writeFileSync(filePath, original.split(from).join(to));
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=replaceInFileExact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceInFileExact.js","sourceRoot":"","sources":["../../../src/lib/replaceInFileExact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,4EAA4E;AAC5E,qDAAqD;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAE,EAAU,EAAQ,EAAE;IACrF,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,QAAQ,QAAQ,6BAA6B,CAAC,CAAC;IAC1F,CAAC;IACD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC","sourcesContent":["import fs from 'fs';\n\n// Replace an exact string in one file, throwing if it isn't there. Targeted\n// edits should fail loudly when the template drifts.\nexport const replaceInFileExact = (filePath: string, from: string, to: string): void => {\n const original = fs.readFileSync(filePath, 'utf8');\n if (!original.includes(from)) {\n throw new Error(`Expected to find \"${from}\" in ${filePath}. Has the template changed?`);\n }\n fs.writeFileSync(filePath, original.split(from).join(to));\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const replaceInFiles: (root: string, replacements: Array<[from: string, to: string]>) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { listFilesRecursive } from './listFilesRecursive';
|
|
4
|
+
// Extensions the rename sweeps are allowed to touch. Everything else
|
|
5
|
+
// (images, favicons, fonts) passes through untouched.
|
|
6
|
+
const TEXT_FILE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.json', '.html', '.css', '.md', '.yml', '.yaml']);
|
|
7
|
+
// Apply literal (non-regex) string replacements to every text file under
|
|
8
|
+
// root. Replacement tokens are chosen to be collision-free ('@todo/',
|
|
9
|
+
// 'apps/todo/'), so this is a mechanical sweep, not a heuristic one.
|
|
10
|
+
export const replaceInFiles = (root, replacements) => {
|
|
11
|
+
for (const filePath of listFilesRecursive(root)) {
|
|
12
|
+
if (!TEXT_FILE_EXTENSIONS.has(path.extname(filePath))) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const original = fs.readFileSync(filePath, 'utf8');
|
|
16
|
+
let updated = original;
|
|
17
|
+
for (const [from, to] of replacements) {
|
|
18
|
+
updated = updated.split(from).join(to);
|
|
19
|
+
}
|
|
20
|
+
if (updated !== original) {
|
|
21
|
+
fs.writeFileSync(filePath, updated);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=replaceInFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceInFiles.js","sourceRoot":"","sources":["../../../src/lib/replaceInFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qEAAqE;AACrE,sDAAsD;AACtD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvI,yEAAyE;AACzE,sEAAsE;AACtE,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,YAA+C,EAAQ,EAAE;IACpG,KAAK,MAAM,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACtD,SAAS;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,QAAQ,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC;YACtC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzB,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { listFilesRecursive } from './listFilesRecursive';\n\n// Extensions the rename sweeps are allowed to touch. Everything else\n// (images, favicons, fonts) passes through untouched.\nconst TEXT_FILE_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.json', '.html', '.css', '.md', '.yml', '.yaml']);\n\n// Apply literal (non-regex) string replacements to every text file under\n// root. Replacement tokens are chosen to be collision-free ('@todo/',\n// 'apps/todo/'), so this is a mechanical sweep, not a heuristic one.\nexport const replaceInFiles = (root: string, replacements: Array<[from: string, to: string]>): void => {\n for (const filePath of listFilesRecursive(root)) {\n if (!TEXT_FILE_EXTENSIONS.has(path.extname(filePath))) {\n continue;\n }\n\n const original = fs.readFileSync(filePath, 'utf8');\n let updated = original;\n for (const [from, to] of replacements) {\n updated = updated.split(from).join(to);\n }\n\n if (updated !== original) {\n fs.writeFileSync(filePath, updated);\n }\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const writeJsonFile: (filePath: string, value: unknown) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeJsonFile.js","sourceRoot":"","sources":["../../../src/lib/writeJsonFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,KAAc,EAAQ,EAAE;IACtE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC,CAAC","sourcesContent":["import fs from 'fs';\n\nexport const writeJsonFile = (filePath: string, value: unknown): void => {\n fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\\n`);\n};\n"]}
|
|
@@ -7,14 +7,14 @@ export const preflight = {
|
|
|
7
7
|
name: 'Checking prerequisites',
|
|
8
8
|
run: async ({ targetDirectory, answers }) => {
|
|
9
9
|
if (!VALID_APP_NAME.test(answers.appName)) {
|
|
10
|
-
throw new Error(`"${answers.appName}" is not a valid app name
|
|
10
|
+
throw new Error(`"${answers.appName}" is not a valid app name: use lowercase letters, digits and hyphens, starting with a letter.`);
|
|
11
11
|
}
|
|
12
12
|
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
|
13
13
|
if (nodeMajor < MINIMUM_NODE_MAJOR) {
|
|
14
|
-
throw new Error(`quidproquo apps require node >= ${MINIMUM_NODE_MAJOR} (you are on ${process.versions.node})
|
|
14
|
+
throw new Error(`quidproquo apps require node >= ${MINIMUM_NODE_MAJOR} (you are on ${process.versions.node}). Upgrade node and re-run.`);
|
|
15
15
|
}
|
|
16
16
|
if (fs.existsSync(targetDirectory)) {
|
|
17
|
-
throw new Error(`${targetDirectory} already exists
|
|
17
|
+
throw new Error(`${targetDirectory} already exists. Pick a different name or remove it first.`);
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"001_preflight.js","sourceRoot":"","sources":["../../../src/steps/001_preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,qEAAqE;AACrE,+BAA+B;AAC/B,MAAM,cAAc,GAAG,mBAAmB,CAAC;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AAG,eAAe,4DAA4D,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\n\nimport { CreateQpqAppStep } from '../types';\n\n// npm-safe, unscoped, url-friendly: lowercase, starts with a letter,\n// letters/digits/hyphens only.\nconst VALID_APP_NAME = /^[a-z][a-z0-9-]*$/;\n\nconst MINIMUM_NODE_MAJOR = 22;\n\nexport const preflight: CreateQpqAppStep = {\n name: 'Checking prerequisites',\n\n run: async ({ targetDirectory, answers }) => {\n if (!VALID_APP_NAME.test(answers.appName)) {\n throw new Error(`\"${answers.appName}\" is not a valid app name: use lowercase letters, digits and hyphens, starting with a letter.`);\n }\n\n const nodeMajor = Number(process.versions.node.split('.')[0]);\n if (nodeMajor < MINIMUM_NODE_MAJOR) {\n throw new Error(`quidproquo apps require node >= ${MINIMUM_NODE_MAJOR} (you are on ${process.versions.node}). Upgrade node and re-run.`);\n }\n\n if (fs.existsSync(targetDirectory)) {\n throw new Error(`${targetDirectory} already exists. Pick a different name or remove it first.`);\n }\n },\n};\n"]}
|
|
@@ -6,7 +6,7 @@ export const copyTemplate = {
|
|
|
6
6
|
name: 'Copying template',
|
|
7
7
|
run: async ({ templateDirectory, targetDirectory }) => {
|
|
8
8
|
if (!fs.existsSync(templateDirectory)) {
|
|
9
|
-
throw new Error(`Template snapshot missing at ${templateDirectory}
|
|
9
|
+
throw new Error(`Template snapshot missing at ${templateDirectory}: run "npm run snapshot-template" (dev checkout only; published packages ship it).`);
|
|
10
10
|
}
|
|
11
11
|
fs.cpSync(templateDirectory, targetDirectory, { recursive: true });
|
|
12
12
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"002_copyTemplate.js","sourceRoot":"","sources":["../../../src/steps/002_copyTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,4EAA4E;AAC5E,2EAA2E;AAC3E,yBAAyB;AACzB,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,IAAI,EAAE,kBAAkB;IAExB,GAAG,EAAE,KAAK,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,EAAE,EAAE;QACpD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,gCAAgC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"002_copyTemplate.js","sourceRoot":"","sources":["../../../src/steps/002_copyTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,4EAA4E;AAC5E,2EAA2E;AAC3E,yBAAyB;AACzB,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,IAAI,EAAE,kBAAkB;IAExB,GAAG,EAAE,KAAK,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,EAAE,EAAE;QACpD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,gCAAgC,iBAAiB,oFAAoF,CACtI,CAAC;QACJ,CAAC;QAED,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\n\nimport { CreateQpqAppStep } from '../types';\n\n// Dumb copy of the bundled template (a pruned snapshot of quidproquojs.com,\n// taken at publish time) into the target directory. All shaping happens in\n// the steps that follow.\nexport const copyTemplate: CreateQpqAppStep = {\n name: 'Copying template',\n\n run: async ({ templateDirectory, targetDirectory }) => {\n if (!fs.existsSync(templateDirectory)) {\n throw new Error(\n `Template snapshot missing at ${templateDirectory}: run \"npm run snapshot-template\" (dev checkout only; published packages ship it).`,\n );\n }\n\n fs.cpSync(templateDirectory, targetDirectory, { recursive: true });\n },\n};\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { readJsonFile
|
|
4
|
-
|
|
3
|
+
import { readJsonFile } from '../lib/readJsonFile';
|
|
4
|
+
import { writeJsonFile } from '../lib/writeJsonFile';
|
|
5
|
+
// The docusaurus workspace is the quidproquojs.com documentation site; new
|
|
5
6
|
// apps don't want it. Remove the directory and its workspaces entry.
|
|
6
7
|
export const deleteDocusaurus = {
|
|
7
8
|
name: 'Removing docusaurus docs site',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"003_deleteDocusaurus.js","sourceRoot":"","sources":["../../../src/steps/003_deleteDocusaurus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"003_deleteDocusaurus.js","sourceRoot":"","sources":["../../../src/steps/003_deleteDocusaurus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,2EAA2E;AAC3E,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,IAAI,EAAE,+BAA+B;IAErC,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACjC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtF,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;QAClD,WAAW,CAAC,UAAU,GAAG,CAAC,WAAW,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC;QAClH,aAAa,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { readJsonFile } from '../lib/readJsonFile';\nimport { writeJsonFile } from '../lib/writeJsonFile';\nimport { CreateQpqAppStep } from '../types';\n\n// The docusaurus workspace is the quidproquojs.com documentation site; new\n// apps don't want it. Remove the directory and its workspaces entry.\nexport const deleteDocusaurus: CreateQpqAppStep = {\n name: 'Removing docusaurus docs site',\n\n run: async ({ targetDirectory }) => {\n fs.rmSync(path.join(targetDirectory, 'docusaurus'), { recursive: true, force: true });\n\n const packageJsonPath = path.join(targetDirectory, 'package.json');\n const packageJson = readJsonFile(packageJsonPath);\n packageJson.workspaces = (packageJson.workspaces ?? []).filter((workspace: string) => workspace !== 'docusaurus');\n writeJsonFile(packageJsonPath, packageJson);\n },\n};\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { readJsonFile
|
|
3
|
+
import { readJsonFile } from '../lib/readJsonFile';
|
|
4
|
+
import { replaceInFileExact } from '../lib/replaceInFileExact';
|
|
5
|
+
import { replaceInFiles } from '../lib/replaceInFiles';
|
|
6
|
+
import { writeJsonFile } from '../lib/writeJsonFile';
|
|
4
7
|
// Give the app its identity. Only targeted, collision-free tokens are
|
|
5
|
-
// rewritten
|
|
8
|
+
// rewritten: the app FOLDER, the package SCOPE and the deploy PREFIX take
|
|
6
9
|
// the app name, while template vocabulary (TodoServiceEnum, services/todo,
|
|
7
10
|
// TodoList, TODO comments) is deliberately left alone so every generated app
|
|
8
11
|
// shares the same internal layout.
|
|
@@ -21,7 +24,7 @@ export const applyAppIdentity = {
|
|
|
21
24
|
// Build/dist and federated-alias paths: dist/apps/todo/... -> dist/apps/myapp/...
|
|
22
25
|
['apps/todo/', `apps/${appName}/`],
|
|
23
26
|
]);
|
|
24
|
-
// The deploy prefix names every stack/resource
|
|
27
|
+
// The deploy prefix names every stack/resource; this is the app name.
|
|
25
28
|
const deployConfigPath = path.join(targetDirectory, 'apps', appName, 'deploy.config.json');
|
|
26
29
|
const deployConfig = readJsonFile(deployConfigPath);
|
|
27
30
|
deployConfig.prefix = appName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"005_applyAppIdentity.js","sourceRoot":"","sources":["../../../src/steps/005_applyAppIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"005_applyAppIdentity.js","sourceRoot":"","sources":["../../../src/steps/005_applyAppIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,sEAAsE;AACtE,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,mCAAmC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,IAAI,EAAE,uBAAuB;IAE7B,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE5B,MAAM,gB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Exact } from '../lib/replaceInFileExact';\nimport { replaceInFiles } from '../lib/replaceInFiles';\nimport { writeJsonFile } from '../lib/writeJsonFile';\nimport { CreateQpqAppStep } from '../types';\n\n// Give the app its identity. Only targeted, collision-free tokens are\n// rewritten: the app FOLDER, the package SCOPE and the deploy PREFIX take\n// the app name, while template vocabulary (TodoServiceEnum, services/todo,\n// TodoList, TODO comments) is deliberately left alone so every generated app\n// shares the same internal layout.\nexport const applyAppIdentity: CreateQpqAppStep = {\n name: 'Applying app identity',\n\n run: async ({ targetDirectory, answers }) => {\n const { appName } = answers;\n\n const todoAppDirectory = path.join(targetDirectory, 'apps', 'todo');\n const appDirectory = path.join(targetDirectory, 'apps', appName);\n if (appName !== 'todo') {\n fs.renameSync(todoAppDirectory, appDirectory);\n }\n\n replaceInFiles(targetDirectory, [\n // Workspace package scope: @todo/constants -> @myapp/constants\n ['@todo/', `@${appName}/`],\n // Build/dist and federated-alias paths: dist/apps/todo/... -> dist/apps/myapp/...\n ['apps/todo/', `apps/${appName}/`],\n ]);\n\n // The deploy prefix names every stack/resource; this is the app name.\n const deployConfigPath = path.join(targetDirectory, 'apps', appName, 'deploy.config.json');\n const deployConfig = readJsonFile(deployConfigPath);\n deployConfig.prefix = appName;\n writeJsonFile(deployConfigPath, deployConfig);\n\n replaceInFileExact(\n path.join(appDirectory, 'packages', 'service-utils', 'src', 'defineTodoService.ts'),\n \"const modulePrefix = 'todo';\",\n `const modulePrefix = '${appName}';`,\n );\n\n const rootPackageJsonPath = path.join(targetDirectory, 'package.json');\n const rootPackageJson = readJsonFile(rootPackageJsonPath);\n rootPackageJson.name = appName;\n writeJsonFile(rootPackageJsonPath, rootPackageJson);\n },\n};\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { readJsonFile
|
|
2
|
+
import { readJsonFile } from '../lib/readJsonFile';
|
|
3
|
+
import { replaceInFileExact } from '../lib/replaceInFileExact';
|
|
4
|
+
import { writeJsonFile } from '../lib/writeJsonFile';
|
|
3
5
|
// The template's domain, replaced wherever it's authoritative: the deploy
|
|
4
6
|
// config and the app's domain constant (everything else derives from those).
|
|
5
7
|
const TEMPLATE_DOMAIN = 'todo.quidproquojs.com';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"006_applyDomain.js","sourceRoot":"","sources":["../../../src/steps/006_applyDomain.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"006_applyDomain.js","sourceRoot":"","sources":["../../../src/steps/006_applyDomain.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,0EAA0E;AAC1E,6EAA6E;AAC7E,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAqB;IAC3C,IAAI,EAAE,iBAAiB;IAEvB,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QACnG,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;QACpD,YAAY,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QACrC,aAAa,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAE9C,kBAAkB,CAChB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC,EAChG,eAAe,EACf,OAAO,CAAC,MAAM,CACf,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import path from 'path';\n\nimport { readJsonFile } from '../lib/readJsonFile';\nimport { replaceInFileExact } from '../lib/replaceInFileExact';\nimport { writeJsonFile } from '../lib/writeJsonFile';\nimport { CreateQpqAppStep } from '../types';\n\n// The template's domain, replaced wherever it's authoritative: the deploy\n// config and the app's domain constant (everything else derives from those).\nconst TEMPLATE_DOMAIN = 'todo.quidproquojs.com';\n\nexport const applyDomain: CreateQpqAppStep = {\n name: 'Applying domain',\n\n run: async ({ targetDirectory, answers }) => {\n const deployConfigPath = path.join(targetDirectory, 'apps', answers.appName, 'deploy.config.json');\n const deployConfig = readJsonFile(deployConfigPath);\n deployConfig.domain = answers.domain;\n writeJsonFile(deployConfigPath, deployConfig);\n\n replaceInFileExact(\n path.join(targetDirectory, 'apps', answers.appName, 'packages', 'constants', 'src', 'domain.ts'),\n TEMPLATE_DOMAIN,\n answers.domain,\n );\n },\n};\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { readJsonFile
|
|
2
|
+
import { readJsonFile } from '../lib/readJsonFile';
|
|
3
|
+
import { writeJsonFile } from '../lib/writeJsonFile';
|
|
3
4
|
// quidproquojs.com lives beside the quidproquo monorepo and consumes it via
|
|
4
5
|
// file:../ refs; a generated app lives anywhere, so those become registry
|
|
5
|
-
// versions pinned to create-qpq-app's own version
|
|
6
|
+
// versions pinned to create-qpq-app's own version; the whole family is
|
|
6
7
|
// published in lockstep, so the versions always exist together.
|
|
7
8
|
export const pinRegistryVersions = {
|
|
8
9
|
name: 'Pinning quidproquo versions',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"007_pinRegistryVersions.js","sourceRoot":"","sources":["../../../src/steps/007_pinRegistryVersions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"007_pinRegistryVersions.js","sourceRoot":"","sources":["../../../src/steps/007_pinRegistryVersions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,4EAA4E;AAC5E,0EAA0E;AAC1E,uEAAuE;AACvE,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACnD,IAAI,EAAE,6BAA6B;IAEnC,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE;QAC7C,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;QAElD,KAAK,MAAM,eAAe,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC;YACtF,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,EAAE,CAAC;gBACpE,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;oBACzE,eAAe,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,aAAa,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC","sourcesContent":["import path from 'path';\n\nimport { readJsonFile } from '../lib/readJsonFile';\nimport { writeJsonFile } from '../lib/writeJsonFile';\nimport { CreateQpqAppStep } from '../types';\n\n// quidproquojs.com lives beside the quidproquo monorepo and consumes it via\n// file:../ refs; a generated app lives anywhere, so those become registry\n// versions pinned to create-qpq-app's own version; the whole family is\n// published in lockstep, so the versions always exist together.\nexport const pinRegistryVersions: CreateQpqAppStep = {\n name: 'Pinning quidproquo versions',\n\n run: async ({ targetDirectory, ownVersion }) => {\n const packageJsonPath = path.join(targetDirectory, 'package.json');\n const packageJson = readJsonFile(packageJsonPath);\n\n for (const dependencyBlock of [packageJson.dependencies, packageJson.devDependencies]) {\n for (const [name, version] of Object.entries(dependencyBlock ?? {})) {\n if (name.startsWith('quidproquo') && String(version).startsWith('file:')) {\n dependencyBlock[name] = ownVersion;\n }\n }\n }\n\n writeJsonFile(packageJsonPath, packageJson);\n },\n};\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { listFilesRecursive
|
|
3
|
+
import { listFilesRecursive } from '../lib/listFilesRecursive';
|
|
4
|
+
import { readJsonFile } from '../lib/readJsonFile';
|
|
5
|
+
import { writeJsonFile } from '../lib/writeJsonFile';
|
|
4
6
|
import { AppLanguage } from '../types';
|
|
5
7
|
// Convert the scaffolded TypeScript app to JavaScript: per-file type
|
|
6
8
|
// stripping (JSX preserved, comments kept), then remove the TypeScript
|
|
@@ -40,7 +42,7 @@ export const transpileToJavaScript = {
|
|
|
40
42
|
}
|
|
41
43
|
const source = fs.readFileSync(filePath, 'utf8');
|
|
42
44
|
const { outputText } = ts.transpileModule(source, { compilerOptions, fileName: filePath });
|
|
43
|
-
// Type-only statements leave blank gaps behind
|
|
45
|
+
// Type-only statements leave blank gaps behind; collapse runs of them.
|
|
44
46
|
const collapsed = outputText.replace(/\n{3,}/g, '\n\n');
|
|
45
47
|
const outputPath = filePath.replace(/\.tsx?$/, isTsx ? '.jsx' : '.js');
|
|
46
48
|
const output = await prettier.format(collapsed, { ...prettierOptions, filepath: outputPath });
|
|
@@ -49,7 +51,7 @@ export const transpileToJavaScript = {
|
|
|
49
51
|
converted += 1;
|
|
50
52
|
}
|
|
51
53
|
// TypeScript build plumbing: tsconfigs, the ambient types/ dir, and the
|
|
52
|
-
// per-package tsc scripts all go. Lib packages no longer build
|
|
54
|
+
// per-package tsc scripts all go. Lib packages no longer build; their
|
|
53
55
|
// package.json main points straight at src.
|
|
54
56
|
let libsRepointed = 0;
|
|
55
57
|
for (const filePath of listFilesRecursive(targetDirectory)) {
|
|
@@ -67,10 +69,10 @@ export const transpileToJavaScript = {
|
|
|
67
69
|
}
|
|
68
70
|
// Lib packages (identified by their tsc build) get served from
|
|
69
71
|
// source. A tsc build with an unexpected main means the template's
|
|
70
|
-
// conventions moved
|
|
72
|
+
// conventions moved: fail loudly rather than scaffold a broken app.
|
|
71
73
|
if (packageJson.scripts?.build === 'tsc -b') {
|
|
72
74
|
if (packageJson.main !== './dist/src/index.js') {
|
|
73
|
-
throw new Error(`${filePath} has a tsc build but main is "${packageJson.main}" (expected "./dist/src/index.js")
|
|
75
|
+
throw new Error(`${filePath} has a tsc build but main is "${packageJson.main}" (expected "./dist/src/index.js"). Update transpileToJavaScript for the new template convention.`);
|
|
74
76
|
}
|
|
75
77
|
packageJson.main = './src/index.js';
|
|
76
78
|
delete packageJson.typings;
|
|
@@ -86,9 +88,9 @@ export const transpileToJavaScript = {
|
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
if (converted === 0 || libsRepointed === 0) {
|
|
89
|
-
throw new Error(`JavaScript conversion looks wrong: ${converted} files transpiled, ${libsRepointed} lib packages repointed
|
|
91
|
+
throw new Error(`JavaScript conversion looks wrong: ${converted} files transpiled, ${libsRepointed} lib packages repointed. Has the template changed shape?`);
|
|
90
92
|
}
|
|
91
|
-
// The ROOT tsconfig.json stays
|
|
93
|
+
// The ROOT tsconfig.json stays: the qpq CLI's ts-node require hook reads
|
|
92
94
|
// its ts-node block, and allowJs makes that hook compile the app's
|
|
93
95
|
// ESM-syntax .js files (imports, __dirname) at load time.
|
|
94
96
|
fs.rmSync(path.join(targetDirectory, 'types'), { recursive: true, force: true });
|
|
@@ -96,7 +98,7 @@ export const transpileToJavaScript = {
|
|
|
96
98
|
const rootTsconfigPath = path.join(targetDirectory, 'tsconfig.json');
|
|
97
99
|
const rootTsconfig = readJsonFile(rootTsconfigPath);
|
|
98
100
|
rootTsconfig['ts-node'].compilerOptions.allowJs = true;
|
|
99
|
-
// Scope the hook to this repo
|
|
101
|
+
// Scope the hook to this repo: allowJs must never recompile quidproquo
|
|
100
102
|
// libs living outside node_modules (file:-linked dev setups).
|
|
101
103
|
rootTsconfig['ts-node'].scope = true;
|
|
102
104
|
rootTsconfig['ts-node'].scopeDir = '.';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"008_transpileToJavaScript.js","sourceRoot":"","sources":["../../../src/steps/008_transpileToJavaScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAoB,MAAM,UAAU,CAAC;AAEzD,qEAAqE;AACrE,uEAAuE;AACvE,0CAA0C;AAC1C,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,oCAAoC;AACpC,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,IAAI,EAAE,0BAA0B;IAEhC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,UAAU;IAEnE,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACjC,wDAAwD;QACxD,0DAA0D;QAC1D,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAC;QAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAA8B,CAAC;QAClE,yDAAyD;QAEzD,0EAA0E;QA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CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QACrE,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;QACpD,YAAY,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;QACvD,wEAAwE;QACxE,8DAA8D;QAC9D,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;QACrC,YAAY,CAAC,SAAS,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;QACvC,aAAa,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAE9C,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACvE,MAAM,eAAe,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAC1D,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;QAChD,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,uBAAuB,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { listFilesRecursive, readJsonFile, writeJsonFile } from '../lib/files';\nimport { AppLanguage, CreateQpqAppStep } from '../types';\n\n// Convert the scaffolded TypeScript app to JavaScript: per-file type\n// stripping (JSX preserved, comments kept), then remove the TypeScript\n// build plumbing the app no longer needs.\n//\n// The qpq toolchain runs the result as-is: the CLI's ts-node require hook\n// compiles the app's ESM-syntax .js at load time (allowJs, added below), and\n// rspack bundles .js/.jsx natively.\nexport const transpileToJavaScript: CreateQpqAppStep = {\n name: 'Converting to JavaScript',\n\n shouldRun: (answers) => answers.language === AppLanguage.javascript,\n\n run: async ({ targetDirectory }) => {\n // Lazy so TypeScript scaffolds never load the compiler.\n /* eslint-disable @typescript-eslint/no-require-imports */\n const ts = require('typescript') as typeof import('typescript');\n const prettier = require('prettier') as typeof import('prettier');\n /* eslint-enable @typescript-eslint/no-require-imports */\n\n // The transpiler re-prints files in its own style; format the output with\n // the app's own prettier settings so generated code matches the repo.\n const prettierRcPath = path.join(targetDirectory, '.prettierrc');\n const prettierOptions = fs.existsSync(prettierRcPath) ? readJsonFile(prettierRcPath) : {};\n\n const compilerOptions: import('typescript').CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext, // keep import/export statements as written\n jsx: ts.JsxEmit.Preserve,\n removeComments: false,\n };\n\n let converted = 0;\n for (const filePath of listFilesRecursive(targetDirectory)) {\n if (filePath.endsWith('.d.ts')) {\n fs.rmSync(filePath);\n continue;\n }\n\n const isTsx = filePath.endsWith('.tsx');\n if (!isTsx && !filePath.endsWith('.ts')) {\n continue;\n }\n\n const source = fs.readFileSync(filePath, 'utf8');\n const { outputText } = ts.transpileModule(source, { compilerOptions, fileName: filePath });\n\n // Type-only statements leave blank gaps behind — collapse runs of them.\n const collapsed = outputText.replace(/\\n{3,}/g, '\\n\\n');\n\n const outputPath = filePath.replace(/\\.tsx?$/, isTsx ? '.jsx' : '.js');\n const output = await prettier.format(collapsed, { ...prettierOptions, filepath: outputPath });\n\n fs.writeFileSync(outputPath, output);\n fs.rmSync(filePath);\n converted += 1;\n }\n\n // TypeScript build plumbing: tsconfigs, the ambient types/ dir, and the\n // per-package tsc scripts all go. Lib packages no longer build — their\n // package.json main points straight at src.\n let libsRepointed = 0;\n for (const filePath of listFilesRecursive(targetDirectory)) {\n const baseName = path.basename(filePath);\n\n if (baseName.startsWith('tsconfig') && baseName.endsWith('.json') && filePath !== path.join(targetDirectory, 'tsconfig.json')) {\n fs.rmSync(filePath);\n continue;\n }\n\n if (baseName === 'package.json' && filePath !== path.join(targetDirectory, 'package.json')) {\n const packageJson = readJsonFile(filePath);\n let changed = false;\n\n if (packageJson.scripts?.['validate-ts']) {\n delete packageJson.scripts['validate-ts'];\n changed = true;\n }\n\n // Lib packages (identified by their tsc build) get served from\n // source. A tsc build with an unexpected main means the template's\n // conventions moved — fail loudly rather than scaffold a broken app.\n if (packageJson.scripts?.build === 'tsc -b') {\n if (packageJson.main !== './dist/src/index.js') {\n throw new Error(\n `${filePath} has a tsc build but main is \"${packageJson.main}\" (expected \"./dist/src/index.js\") — update transpileToJavaScript for the new template convention.`,\n );\n }\n\n packageJson.main = './src/index.js';\n delete packageJson.typings;\n delete packageJson.scripts.build;\n packageJson.exports = { '.': { default: './src/index.js' } };\n packageJson.files = ['src'];\n changed = true;\n libsRepointed += 1;\n }\n\n if (changed) {\n writeJsonFile(filePath, packageJson);\n }\n }\n }\n\n if (converted === 0 || libsRepointed === 0) {\n throw new Error(\n `JavaScript conversion looks wrong: ${converted} files transpiled, ${libsRepointed} lib packages repointed — has the template changed shape?`,\n );\n }\n\n // The ROOT tsconfig.json stays — the qpq CLI's ts-node require hook reads\n // its ts-node block, and allowJs makes that hook compile the app's\n // ESM-syntax .js files (imports, __dirname) at load time.\n fs.rmSync(path.join(targetDirectory, 'types'), { recursive: true, force: true });\n fs.rmSync(path.join(targetDirectory, 'tsconfig.base.json'), { force: true });\n\n const rootTsconfigPath = path.join(targetDirectory, 'tsconfig.json');\n const rootTsconfig = readJsonFile(rootTsconfigPath);\n rootTsconfig['ts-node'].compilerOptions.allowJs = true;\n // Scope the hook to this repo — allowJs must never recompile quidproquo\n // libs living outside node_modules (file:-linked dev setups).\n rootTsconfig['ts-node'].scope = true;\n rootTsconfig['ts-node'].scopeDir = '.';\n writeJsonFile(rootTsconfigPath, rootTsconfig);\n\n const rootPackageJsonPath = path.join(targetDirectory, 'package.json');\n const rootPackageJson = readJsonFile(rootPackageJsonPath);\n delete rootPackageJson.scripts?.['validate-ts'];\n writeJsonFile(rootPackageJsonPath, rootPackageJson);\n\n console.log(` Converted ${converted} files to JavaScript.`);\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"008_transpileToJavaScript.js","sourceRoot":"","sources":["../../../src/steps/008_transpileToJavaScript.ts"],"names":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AAC,CAAC;QACvE,MAAM,eAAe,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAC1D,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;QAChD,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,uBAAuB,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { listFilesRecursive } from '../lib/listFilesRecursive';\nimport { readJsonFile } from '../lib/readJsonFile';\nimport { writeJsonFile } from '../lib/writeJsonFile';\nimport { AppLanguage, CreateQpqAppStep } from '../types';\n\n// Convert the scaffolded TypeScript app to JavaScript: per-file type\n// stripping (JSX preserved, comments kept), then remove the TypeScript\n// build plumbing the app no longer needs.\n//\n// The qpq toolchain runs the result as-is: the CLI's ts-node require hook\n// compiles the app's ESM-syntax .js at load time (allowJs, added below), and\n// rspack bundles .js/.jsx natively.\nexport const transpileToJavaScript: CreateQpqAppStep = {\n name: 'Converting to JavaScript',\n\n shouldRun: (answers) => answers.language === AppLanguage.javascript,\n\n run: async ({ targetDirectory }) => {\n // Lazy so TypeScript scaffolds never load the compiler.\n /* eslint-disable @typescript-eslint/no-require-imports */\n const ts = require('typescript') as typeof import('typescript');\n const prettier = require('prettier') as typeof import('prettier');\n /* eslint-enable @typescript-eslint/no-require-imports */\n\n // The transpiler re-prints files in its own style; format the output with\n // the app's own prettier settings so generated code matches the repo.\n const prettierRcPath = path.join(targetDirectory, '.prettierrc');\n const prettierOptions = fs.existsSync(prettierRcPath) ? readJsonFile(prettierRcPath) : {};\n\n const compilerOptions: import('typescript').CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext, // keep import/export statements as written\n jsx: ts.JsxEmit.Preserve,\n removeComments: false,\n };\n\n let converted = 0;\n for (const filePath of listFilesRecursive(targetDirectory)) {\n if (filePath.endsWith('.d.ts')) {\n fs.rmSync(filePath);\n continue;\n }\n\n const isTsx = filePath.endsWith('.tsx');\n if (!isTsx && !filePath.endsWith('.ts')) {\n continue;\n }\n\n const source = fs.readFileSync(filePath, 'utf8');\n const { outputText } = ts.transpileModule(source, { compilerOptions, fileName: filePath });\n\n // Type-only statements leave blank gaps behind; collapse runs of them.\n const collapsed = outputText.replace(/\\n{3,}/g, '\\n\\n');\n\n const outputPath = filePath.replace(/\\.tsx?$/, isTsx ? '.jsx' : '.js');\n const output = await prettier.format(collapsed, { ...prettierOptions, filepath: outputPath });\n\n fs.writeFileSync(outputPath, output);\n fs.rmSync(filePath);\n converted += 1;\n }\n\n // TypeScript build plumbing: tsconfigs, the ambient types/ dir, and the\n // per-package tsc scripts all go. Lib packages no longer build; their\n // package.json main points straight at src.\n let libsRepointed = 0;\n for (const filePath of listFilesRecursive(targetDirectory)) {\n const baseName = path.basename(filePath);\n\n if (baseName.startsWith('tsconfig') && baseName.endsWith('.json') && filePath !== path.join(targetDirectory, 'tsconfig.json')) {\n fs.rmSync(filePath);\n continue;\n }\n\n if (baseName === 'package.json' && filePath !== path.join(targetDirectory, 'package.json')) {\n const packageJson = readJsonFile(filePath);\n let changed = false;\n\n if (packageJson.scripts?.['validate-ts']) {\n delete packageJson.scripts['validate-ts'];\n changed = true;\n }\n\n // Lib packages (identified by their tsc build) get served from\n // source. A tsc build with an unexpected main means the template's\n // conventions moved: fail loudly rather than scaffold a broken app.\n if (packageJson.scripts?.build === 'tsc -b') {\n if (packageJson.main !== './dist/src/index.js') {\n throw new Error(\n `${filePath} has a tsc build but main is \"${packageJson.main}\" (expected \"./dist/src/index.js\"). Update transpileToJavaScript for the new template convention.`,\n );\n }\n\n packageJson.main = './src/index.js';\n delete packageJson.typings;\n delete packageJson.scripts.build;\n packageJson.exports = { '.': { default: './src/index.js' } };\n packageJson.files = ['src'];\n changed = true;\n libsRepointed += 1;\n }\n\n if (changed) {\n writeJsonFile(filePath, packageJson);\n }\n }\n }\n\n if (converted === 0 || libsRepointed === 0) {\n throw new Error(\n `JavaScript conversion looks wrong: ${converted} files transpiled, ${libsRepointed} lib packages repointed. Has the template changed shape?`,\n );\n }\n\n // The ROOT tsconfig.json stays: the qpq CLI's ts-node require hook reads\n // its ts-node block, and allowJs makes that hook compile the app's\n // ESM-syntax .js files (imports, __dirname) at load time.\n fs.rmSync(path.join(targetDirectory, 'types'), { recursive: true, force: true });\n fs.rmSync(path.join(targetDirectory, 'tsconfig.base.json'), { force: true });\n\n const rootTsconfigPath = path.join(targetDirectory, 'tsconfig.json');\n const rootTsconfig = readJsonFile(rootTsconfigPath);\n rootTsconfig['ts-node'].compilerOptions.allowJs = true;\n // Scope the hook to this repo: allowJs must never recompile quidproquo\n // libs living outside node_modules (file:-linked dev setups).\n rootTsconfig['ts-node'].scope = true;\n rootTsconfig['ts-node'].scopeDir = '.';\n writeJsonFile(rootTsconfigPath, rootTsconfig);\n\n const rootPackageJsonPath = path.join(targetDirectory, 'package.json');\n const rootPackageJson = readJsonFile(rootPackageJsonPath);\n delete rootPackageJson.scripts?.['validate-ts'];\n writeJsonFile(rootPackageJsonPath, rootPackageJson);\n\n console.log(` Converted ${converted} files to JavaScript.`);\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { listFilesRecursive } from '../lib/
|
|
3
|
+
import { listFilesRecursive } from '../lib/listFilesRecursive';
|
|
4
4
|
// npm strips .gitignore files from published tarballs, so the snapshot stores
|
|
5
5
|
// them dotless (the create-react-app trick); restore the dots here.
|
|
6
6
|
export const restoreGitignore = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"009_restoreGitignore.js","sourceRoot":"","sources":["../../../src/steps/009_restoreGitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"009_restoreGitignore.js","sourceRoot":"","sources":["../../../src/steps/009_restoreGitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,8EAA8E;AAC9E,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,IAAI,EAAE,4BAA4B;IAElC,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACjC,KAAK,MAAM,QAAQ,IAAI,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC3D,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,WAAW,EAAE,CAAC;gBAC5C,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { listFilesRecursive } from '../lib/listFilesRecursive';\nimport { CreateQpqAppStep } from '../types';\n\n// npm strips .gitignore files from published tarballs, so the snapshot stores\n// them dotless (the create-react-app trick); restore the dots here.\nexport const restoreGitignore: CreateQpqAppStep = {\n name: 'Restoring .gitignore files',\n\n run: async ({ targetDirectory }) => {\n for (const filePath of listFilesRecursive(targetDirectory)) {\n if (path.basename(filePath) === 'gitignore') {\n fs.renameSync(filePath, path.join(path.dirname(filePath), '.gitignore'));\n }\n }\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runCommand } from '../lib/runCommand';
|
|
2
2
|
// A fresh repo with one clean commit. Failure here (no git installed, odd
|
|
3
|
-
// global config) shouldn't lose the scaffold
|
|
3
|
+
// global config) shouldn't lose the scaffold: warn and carry on.
|
|
4
4
|
export const gitInit = {
|
|
5
5
|
name: 'Initialising git repository',
|
|
6
6
|
shouldRun: (answers) => answers.initialiseGit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"010_gitInit.js","sourceRoot":"","sources":["../../../src/steps/010_gitInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,0EAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"010_gitInit.js","sourceRoot":"","sources":["../../../src/steps/010_gitInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,CAAC,MAAM,OAAO,GAAqB;IACvC,IAAI,EAAE,6BAA6B;IAEnC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa;IAE7C,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;QACjC,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;YAC5D,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;YACjE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,sCAAsC,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;QAC9G,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,wBAAyB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import { runCommand } from '../lib/runCommand';\nimport { CreateQpqAppStep } from '../types';\n\n// A fresh repo with one clean commit. Failure here (no git installed, odd\n// global config) shouldn't lose the scaffold: warn and carry on.\nexport const gitInit: CreateQpqAppStep = {\n name: 'Initialising git repository',\n\n shouldRun: (answers) => answers.initialiseGit,\n\n run: async ({ targetDirectory }) => {\n try {\n await runCommand('git', ['init'], { cwd: targetDirectory });\n await runCommand('git', ['add', '-A'], { cwd: targetDirectory });\n await runCommand('git', ['commit', '-m', '\"Initial commit from create-qpq-app\"'], { cwd: targetDirectory });\n } catch (error) {\n console.warn(` Skipping git init: ${(error as Error).message}`);\n }\n },\n};\n"]}
|
|
@@ -5,7 +5,7 @@ export const printNextSteps = {
|
|
|
5
5
|
console.log(`
|
|
6
6
|
Created ${answers.appName}!
|
|
7
7
|
|
|
8
|
-
Your app has five services
|
|
8
|
+
Your app has five services (admin, auth, design, shell and todo) and
|
|
9
9
|
deploys as a single docker image.
|
|
10
10
|
|
|
11
11
|
Next steps:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"013_printNextSteps.js","sourceRoot":"","sources":["../../../src/steps/013_printNextSteps.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,IAAI,EAAE,MAAM;IAEZ,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kCAAkC,CAAC;QAEtF,OAAO,CAAC,GAAG,CAAC;UACN,OAAO,CAAC,OAAO;;;;;;;OAOlB,OAAO,CAAC,OAAO;EACpB,OAAO;;;8BAGqB,OAAO,CAAC,OAAO,gCAAgC,OAAO,CAAC,MAAM;CAC1F,CAAC,CAAC;IACD,CAAC;CACF,CAAC","sourcesContent":["import { CreateQpqAppStep } from '../types';\n\nexport const printNextSteps: CreateQpqAppStep = {\n name: 'Done',\n\n run: async ({ answers }) => {\n const install = answers.installDependencies ? '' : ' npm install\\n npm run build\\n';\n\n console.log(`\nCreated ${answers.appName}!\n\nYour app has five services
|
|
1
|
+
{"version":3,"file":"013_printNextSteps.js","sourceRoot":"","sources":["../../../src/steps/013_printNextSteps.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,IAAI,EAAE,MAAM;IAEZ,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kCAAkC,CAAC;QAEtF,OAAO,CAAC,GAAG,CAAC;UACN,OAAO,CAAC,OAAO;;;;;;;OAOlB,OAAO,CAAC,OAAO;EACpB,OAAO;;;8BAGqB,OAAO,CAAC,OAAO,gCAAgC,OAAO,CAAC,MAAM;CAC1F,CAAC,CAAC;IACD,CAAC;CACF,CAAC","sourcesContent":["import { CreateQpqAppStep } from '../types';\n\nexport const printNextSteps: CreateQpqAppStep = {\n name: 'Done',\n\n run: async ({ answers }) => {\n const install = answers.installDependencies ? '' : ' npm install\\n npm run build\\n';\n\n console.log(`\nCreated ${answers.appName}!\n\nYour app has five services (admin, auth, design, shell and todo) and\ndeploys as a single docker image.\n\nNext steps:\n\n cd ${answers.appName}\n${install} npm run dev # api on http://localhost:8080, web on http://localhost:3080\n npm run deploy # build the docker image (then run the printed docker command)\n\nDeploy config lives in apps/${answers.appName}/deploy.config.json (domain: ${answers.domain}).\n`);\n },\n};\n"]}
|
package/lib/esm/steps/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { gitInit } from './010_gitInit';
|
|
|
11
11
|
import { npmInstall } from './011_npmInstall';
|
|
12
12
|
import { buildWorkspaces } from './012_buildWorkspaces';
|
|
13
13
|
import { printNextSteps } from './013_printNextSteps';
|
|
14
|
-
// The pipeline: always this list, always this order
|
|
14
|
+
// The pipeline: always this list, always this order; the numeric file
|
|
15
15
|
// prefixes match, so the steps directory reads top to bottom. Steps decide
|
|
16
16
|
// for themselves (shouldRun) whether the collected answers apply to them.
|
|
17
17
|
export const createQpqAppSteps = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/steps/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/steps/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,sEAAsE;AACtE,2EAA2E;AAC3E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAuB;IACnD,SAAS;IACT,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,qBAAqB;IACrB,gBAAgB;IAChB,OAAO;IACP,UAAU;IACV,eAAe;IACf,cAAc;CACf,CAAC;AAEF,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,qBAAqB,GACtB,CAAC","sourcesContent":["import { CreateQpqAppStep } from '../types';\nimport { preflight } from './001_preflight';\nimport { copyTemplate } from './002_copyTemplate';\nimport { deleteDocusaurus } from './003_deleteDocusaurus';\nimport { deleteQpqjsApp } from './004_deleteQpqjsApp';\nimport { applyAppIdentity } from './005_applyAppIdentity';\nimport { applyDomain } from './006_applyDomain';\nimport { pinRegistryVersions } from './007_pinRegistryVersions';\nimport { transpileToJavaScript } from './008_transpileToJavaScript';\nimport { restoreGitignore } from './009_restoreGitignore';\nimport { gitInit } from './010_gitInit';\nimport { npmInstall } from './011_npmInstall';\nimport { buildWorkspaces } from './012_buildWorkspaces';\nimport { printNextSteps } from './013_printNextSteps';\n\n// The pipeline: always this list, always this order; the numeric file\n// prefixes match, so the steps directory reads top to bottom. Steps decide\n// for themselves (shouldRun) whether the collected answers apply to them.\nexport const createQpqAppSteps: CreateQpqAppStep[] = [\n preflight,\n copyTemplate,\n deleteDocusaurus,\n deleteQpqjsApp,\n applyAppIdentity,\n applyDomain,\n pinRegistryVersions,\n transpileToJavaScript,\n restoreGitignore,\n gitInit,\n npmInstall,\n buildWorkspaces,\n printNextSteps,\n];\n\nexport {\n applyAppIdentity,\n applyDomain,\n buildWorkspaces,\n copyTemplate,\n deleteDocusaurus,\n deleteQpqjsApp,\n gitInit,\n npmInstall,\n pinRegistryVersions,\n preflight,\n printNextSteps,\n restoreGitignore,\n transpileToJavaScript,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppLanguage.js","sourceRoot":"","sources":["../../../src/types/AppLanguage.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;AAC3B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","sourcesContent":["export enum AppLanguage {\n typescript = 'typescript',\n javascript = 'javascript',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateQpqAppAnswers.js","sourceRoot":"","sources":["../../../src/types/CreateQpqAppAnswers.ts"],"names":[],"mappings":"","sourcesContent":["import { AppLanguage } from './AppLanguage';\n\n// Everything the pipeline needs to know, collected ONCE (flags first, prompts\n// for whatever is still missing) before any step runs: steps never prompt.\nexport type CreateQpqAppAnswers = {\n appName: string;\n language: AppLanguage;\n domain: string;\n initialiseGit: boolean;\n installDependencies: boolean;\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateQpqAppAnswers } from './CreateQpqAppAnswers';
|
|
2
|
+
import { StepContext } from './StepContext';
|
|
3
|
+
export type CreateQpqAppStep = {
|
|
4
|
+
name: string;
|
|
5
|
+
shouldRun?: (answers: CreateQpqAppAnswers) => boolean;
|
|
6
|
+
run: (context: StepContext) => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateQpqAppStep.js","sourceRoot":"","sources":["../../../src/types/CreateQpqAppStep.ts"],"names":[],"mappings":"","sourcesContent":["import { CreateQpqAppAnswers } from './CreateQpqAppAnswers';\nimport { StepContext } from './StepContext';\n\n// A self-contained scaffolding step. The pipeline always runs the same list\n// top to bottom; each step owns its applicability via shouldRun.\nexport type CreateQpqAppStep = {\n name: string;\n shouldRun?: (answers: CreateQpqAppAnswers) => boolean;\n run: (context: StepContext) => Promise<void>;\n};\n"]}
|