@modular-react/cli-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +41 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/create-journey.d.ts +17 -0
- package/dist/commands/create-journey.d.ts.map +1 -0
- package/dist/commands/create-journey.js +193 -0
- package/dist/commands/create-journey.js.map +1 -0
- package/dist/commands/create-module.d.ts +17 -0
- package/dist/commands/create-module.d.ts.map +1 -0
- package/dist/commands/create-module.js +112 -0
- package/dist/commands/create-module.js.map +1 -0
- package/dist/commands/create-store.d.ts +9 -0
- package/dist/commands/create-store.d.ts.map +1 -0
- package/dist/commands/create-store.js +68 -0
- package/dist/commands/create-store.js.map +1 -0
- package/dist/commands/init.d.ts +17 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +184 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/naming.d.ts +4 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +15 -0
- package/dist/naming.js.map +1 -0
- package/dist/preset.d.ts +112 -0
- package/dist/preset.d.ts.map +1 -0
- package/dist/preset.js +2 -0
- package/dist/preset.js.map +1 -0
- package/dist/runtime-versions.d.ts +15 -0
- package/dist/runtime-versions.d.ts.map +1 -0
- package/dist/runtime-versions.js +15 -0
- package/dist/runtime-versions.js.map +1 -0
- package/dist/templates/app-shared.d.ts +8 -0
- package/dist/templates/app-shared.d.ts.map +1 -0
- package/dist/templates/app-shared.js +63 -0
- package/dist/templates/app-shared.js.map +1 -0
- package/dist/templates/journey.d.ts +30 -0
- package/dist/templates/journey.d.ts.map +1 -0
- package/dist/templates/journey.js +166 -0
- package/dist/templates/journey.js.map +1 -0
- package/dist/templates/module.d.ts +8 -0
- package/dist/templates/module.d.ts.map +1 -0
- package/dist/templates/module.js +43 -0
- package/dist/templates/module.js.map +1 -0
- package/dist/templates/shell.d.ts +25 -0
- package/dist/templates/shell.d.ts.map +1 -0
- package/dist/templates/shell.js +162 -0
- package/dist/templates/shell.js.map +1 -0
- package/dist/templates/store.d.ts +6 -0
- package/dist/templates/store.d.ts.map +1 -0
- package/dist/templates/store.js +10 -0
- package/dist/templates/store.js.map +1 -0
- package/dist/templates/workspace.d.ts +8 -0
- package/dist/templates/workspace.d.ts.map +1 -0
- package/dist/templates/workspace.js +58 -0
- package/dist/templates/workspace.js.map +1 -0
- package/dist/utils/detect-scope.d.ts +2 -0
- package/dist/utils/detect-scope.d.ts.map +1 -0
- package/dist/utils/detect-scope.js +13 -0
- package/dist/utils/detect-scope.js.map +1 -0
- package/dist/utils/prompt.d.ts +14 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +26 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/resolve-project.d.ts +9 -0
- package/dist/utils/resolve-project.d.ts.map +1 -0
- package/dist/utils/resolve-project.js +22 -0
- package/dist/utils/resolve-project.js.map +1 -0
- package/dist/utils/transform.d.ts +83 -0
- package/dist/utils/transform.d.ts.map +1 -0
- package/dist/utils/transform.js +250 -0
- package/dist/utils/transform.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { RUNTIME_VERSIONS } from "../runtime-versions.js";
|
|
2
|
+
export function journeyPackageJson(params) {
|
|
3
|
+
const moduleDeps = Object.fromEntries(params.modules.map((m) => [m.packageName, "workspace:*"]));
|
|
4
|
+
return JSON.stringify({
|
|
5
|
+
name: `${params.scope}/${params.journeyName}-journey`,
|
|
6
|
+
version: "0.1.0",
|
|
7
|
+
type: "module",
|
|
8
|
+
main: "./src/index.ts",
|
|
9
|
+
types: "./src/index.ts",
|
|
10
|
+
exports: {
|
|
11
|
+
".": {
|
|
12
|
+
import: "./src/index.ts",
|
|
13
|
+
types: "./src/index.ts",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
scripts: {
|
|
17
|
+
typecheck: "tsc --noEmit",
|
|
18
|
+
},
|
|
19
|
+
dependencies: {
|
|
20
|
+
"@modular-react/journeys": RUNTIME_VERSIONS.journeys,
|
|
21
|
+
[`${params.scope}/app-shared`]: "workspace:*",
|
|
22
|
+
...moduleDeps,
|
|
23
|
+
},
|
|
24
|
+
devDependencies: {
|
|
25
|
+
typescript: "^6.0.2",
|
|
26
|
+
},
|
|
27
|
+
}, null, 2);
|
|
28
|
+
}
|
|
29
|
+
export function journeyTsconfig() {
|
|
30
|
+
return JSON.stringify({
|
|
31
|
+
extends: "../../tsconfig.base.json",
|
|
32
|
+
include: ["src"],
|
|
33
|
+
}, null, 2);
|
|
34
|
+
}
|
|
35
|
+
export function journeyIndex(params) {
|
|
36
|
+
const journeyExport = `${params.journeyCamel}Journey`;
|
|
37
|
+
const handleExport = `${params.journeyCamel}Handle`;
|
|
38
|
+
const inputType = `${params.journeyPascal}Input`;
|
|
39
|
+
const stateType = `${params.journeyPascal}State`;
|
|
40
|
+
const handleType = `${params.journeyPascal}Handle`;
|
|
41
|
+
return `export {
|
|
42
|
+
${journeyExport},
|
|
43
|
+
${handleExport},
|
|
44
|
+
type ${inputType},
|
|
45
|
+
type ${stateType},
|
|
46
|
+
type ${handleType},
|
|
47
|
+
} from './${params.journeyName}.js'
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
export function journeyDefinition(params) {
|
|
51
|
+
const journeyExport = `${params.journeyCamel}Journey`;
|
|
52
|
+
const handleExport = `${params.journeyCamel}Handle`;
|
|
53
|
+
const inputType = `${params.journeyPascal}Input`;
|
|
54
|
+
const stateType = `${params.journeyPascal}State`;
|
|
55
|
+
const handleType = `${params.journeyPascal}Handle`;
|
|
56
|
+
const modulesType = `${params.journeyPascal}Modules`;
|
|
57
|
+
// Build the modules type-map. Always type-only — journeys don't pull
|
|
58
|
+
// module bundles into their package.
|
|
59
|
+
const moduleImports = params.modules
|
|
60
|
+
.map((m) => `import type ${m.importName}Module from '${m.packageName}'`)
|
|
61
|
+
.join("\n");
|
|
62
|
+
const modulesEntries = params.modules
|
|
63
|
+
.map((m) => ` readonly ${m.importName}: typeof ${m.importName}Module;`)
|
|
64
|
+
.join("\n");
|
|
65
|
+
// Pick the first listed module as the journey's `start` step. If the
|
|
66
|
+
// user didn't list any (the default), emit a hand-fillable stub the
|
|
67
|
+
// typechecker will flag once they wire up real entries.
|
|
68
|
+
const firstModule = params.modules[0];
|
|
69
|
+
const startBlock = firstModule
|
|
70
|
+
? ` start: (state) => ({
|
|
71
|
+
module: '${firstModule.importName}',
|
|
72
|
+
// TODO: pick an entry name your ${firstModule.importName} module exposes via entryPoints.
|
|
73
|
+
entry: 'TODO_entry_name' as const,
|
|
74
|
+
input: state,
|
|
75
|
+
}),`
|
|
76
|
+
: ` start: (_state) => {
|
|
77
|
+
// TODO: return the first step to enter, e.g.:
|
|
78
|
+
// return { module: 'profile', entry: 'review', input: { customerId: state.customerId } }
|
|
79
|
+
throw new Error('Define the start step for ${params.journeyName} journey.')
|
|
80
|
+
},`;
|
|
81
|
+
const transitionsBlock = firstModule
|
|
82
|
+
? ` transitions: {
|
|
83
|
+
${firstModule.importName}: {
|
|
84
|
+
// TODO: list each entry name you handle and one branch per exit it can emit.
|
|
85
|
+
// Example shape:
|
|
86
|
+
// <entry>: {
|
|
87
|
+
// <exitName>: ({ output, state }) => ({ complete: { ... } }),
|
|
88
|
+
// cancelled: () => ({ abort: { reason: 'cancelled' } }),
|
|
89
|
+
// }
|
|
90
|
+
},
|
|
91
|
+
},`
|
|
92
|
+
: ` transitions: {
|
|
93
|
+
// TODO: per-module transition map. Each key is a module from ${modulesType}; the
|
|
94
|
+
// value lists entries you handle and the exits each entry can emit.
|
|
95
|
+
},`;
|
|
96
|
+
return `import { defineJourney, defineJourneyHandle } from '@modular-react/journeys'
|
|
97
|
+
${moduleImports || "// TODO: import type <yourModule> from '@scope/<your>-module' and add it to " + modulesType}
|
|
98
|
+
|
|
99
|
+
// All module imports are \`import type\` — the runtime resolves entries by id
|
|
100
|
+
// against the registered descriptors, so this package stays bundle-free of
|
|
101
|
+
// module code.
|
|
102
|
+
type ${modulesType} = {
|
|
103
|
+
${modulesEntries || " // readonly profile: typeof profileModule;"}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface ${inputType} {
|
|
107
|
+
// TODO: shape the input the caller passes to runtime.start(handle, input).
|
|
108
|
+
readonly customerId: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ${stateType} {
|
|
112
|
+
// TODO: shape the state shared across steps. Keep it serializable —
|
|
113
|
+
// persistence adapters round-trip it via JSON.
|
|
114
|
+
readonly customerId: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const ${journeyExport} = defineJourney<${modulesType}, ${stateType}>()({
|
|
118
|
+
id: '${params.journeyName}',
|
|
119
|
+
version: '1.0.0',
|
|
120
|
+
meta: {
|
|
121
|
+
name: '${params.journeyPascal}',
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
initialState: ({ customerId }: ${inputType}) => ({
|
|
125
|
+
customerId,
|
|
126
|
+
}),
|
|
127
|
+
|
|
128
|
+
${startBlock}
|
|
129
|
+
|
|
130
|
+
${transitionsBlock}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Typed token for opening this journey. Modules and shells import this
|
|
135
|
+
* (via \`import type\`) to call \`runtime.start(handle, input)\` with full
|
|
136
|
+
* input checking — without pulling the journey's runtime into the caller.
|
|
137
|
+
*/
|
|
138
|
+
export const ${handleExport} = defineJourneyHandle(${journeyExport})
|
|
139
|
+
export type ${handleType} = typeof ${handleExport}
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Optional `shell/src/<journey>-persistence.ts`. Generated only when the
|
|
144
|
+
* user passes `--persistence`. Uses `createWebStoragePersistence` and a
|
|
145
|
+
* sensible per-customer key.
|
|
146
|
+
*/
|
|
147
|
+
export function journeyPersistence(params) {
|
|
148
|
+
const inputType = `${params.journeyPascal}Input`;
|
|
149
|
+
const stateType = `${params.journeyPascal}State`;
|
|
150
|
+
return `import { createWebStoragePersistence } from '@modular-react/journeys'
|
|
151
|
+
import type { ${inputType}, ${stateType} } from '${params.scope}/${params.journeyName}-journey'
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* localStorage-backed persistence for the ${params.journeyName} journey.
|
|
155
|
+
* One key per (customerId, journey) pair: starting the journey for the
|
|
156
|
+
* same customer twice resumes the active instance instead of minting a
|
|
157
|
+
* fresh one (see \`JourneyRuntime.start\` idempotency semantics).
|
|
158
|
+
*
|
|
159
|
+
* Pass this to \`registry.registerJourney(${params.journeyCamel}Journey, { persistence })\`.
|
|
160
|
+
*/
|
|
161
|
+
export const ${params.journeyCamel}Persistence = createWebStoragePersistence<${inputType}, ${stateType}>({
|
|
162
|
+
keyFor: ({ journeyId, input }) => \`journey:\${input.customerId}:\${journeyId}\`,
|
|
163
|
+
})
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=journey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey.js","sourceRoot":"","sources":["../../src/templates/journey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAuB1D,MAAM,UAAU,kBAAkB,CAAC,MAA6B;IAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,aAAuB,CAAC,CAAC,CACpE,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,GAAG,MAAM,CAAC,KAAK,IA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C,SAAS;;;;;mBAKT,SAAS;;;;;;eAMb,aAAa,oBAAoB,WAAW,KAAK,SAAS;SAChE,MAAM,CAAC,WAAW;;;aAGd,MAAM,CAAC,aAAa;;;mCAGE,SAAS;;;;EAI1C,UAAU;;EAEV,gBAAgB;;;;;;;;eAQH,YAAY,0BAA0B,aAAa;cACpD,UAAU,aAAa,YAAY;CAChD,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA6B;IAC9D,MAAM,SAAS,GAAG,GAAG,MAAM,CAAC,aAAa,OAAO,CAAC;IACjD,MAAM,SAAS,GAAG,GAAG,MAAM,CAAC,aAAa,OAAO,CAAC;IACjD,OAAO;gBACO,SAAS,KAAK,SAAS,YAAY,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,WAAW;;;6CAGxC,MAAM,CAAC,WAAW;;;;;6CAKlB,MAAM,CAAC,YAAY;;eAEjD,MAAM,CAAC,YAAY,6CAA6C,SAAS,KAAK,SAAS;;;CAGrG,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/templates/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;CACnB,GAAG,MAAM,CAwCT;AAED,wBAAgB,cAAc,IAAI,MAAM,CASvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function modulePackageJson(params) {
|
|
2
|
+
const { router, routerVersion, core } = params.preset.packages;
|
|
3
|
+
return JSON.stringify({
|
|
4
|
+
name: `${params.scope}/${params.name}-module`,
|
|
5
|
+
version: "0.1.0",
|
|
6
|
+
type: "module",
|
|
7
|
+
main: "./src/index.ts",
|
|
8
|
+
types: "./src/index.ts",
|
|
9
|
+
exports: {
|
|
10
|
+
".": {
|
|
11
|
+
import: "./src/index.ts",
|
|
12
|
+
types: "./src/index.ts",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
dependencies: {
|
|
16
|
+
"@modular-react/core": "^1.0.0",
|
|
17
|
+
[core]: "^2.0.0",
|
|
18
|
+
[`${params.scope}/app-shared`]: "workspace:*",
|
|
19
|
+
"@lokalise/frontend-http-client": "^7.0.0",
|
|
20
|
+
},
|
|
21
|
+
peerDependencies: {
|
|
22
|
+
"@tanstack/react-query": "^5.95.0",
|
|
23
|
+
[router]: routerVersion,
|
|
24
|
+
react: "^19.0.0",
|
|
25
|
+
zustand: "^5.0.0",
|
|
26
|
+
},
|
|
27
|
+
devDependencies: {
|
|
28
|
+
"@tanstack/react-query": "^5.95.0",
|
|
29
|
+
[router]: routerVersion,
|
|
30
|
+
react: "^19.0.0",
|
|
31
|
+
zustand: "^5.0.0",
|
|
32
|
+
"@types/react": "^19.0.0",
|
|
33
|
+
typescript: "^6.0.2",
|
|
34
|
+
},
|
|
35
|
+
}, null, 2);
|
|
36
|
+
}
|
|
37
|
+
export function moduleTsconfig() {
|
|
38
|
+
return JSON.stringify({
|
|
39
|
+
extends: "../../tsconfig.base.json",
|
|
40
|
+
include: ["src"],
|
|
41
|
+
}, null, 2);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/templates/module.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,MAIjC;IACC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IAE/D,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,SAAS;QAC7C,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,gBAAgB;QACvB,OAAO,EAAE;YACP,GAAG,EAAE;gBACH,MAAM,EAAE,gBAAgB;gBACxB,KAAK,EAAE,gBAAgB;aACxB;SACF;QACD,YAAY,EAAE;YACZ,qBAAqB,EAAE,QAAQ;YAC/B,CAAC,IAAI,CAAC,EAAE,QAAQ;YAChB,CAAC,GAAG,MAAM,CAAC,KAAK,aAAa,CAAC,EAAE,aAAa;YAC7C,gCAAgC,EAAE,QAAQ;SAC3C;QACD,gBAAgB,EAAE;YAChB,uBAAuB,EAAE,SAAS;YAClC,CAAC,MAAM,CAAC,EAAE,aAAa;YACvB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,QAAQ;SAClB;QACD,eAAe,EAAE;YACf,uBAAuB,EAAE,SAAS;YAClC,CAAC,MAAM,CAAC,EAAE,aAAa;YACvB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,QAAQ;YACjB,cAAc,EAAE,SAAS;YACzB,UAAU,EAAE,QAAQ;SACrB;KACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,CAAC,KAAK,CAAC;KACjB,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CliPreset } from "../preset.js";
|
|
2
|
+
export declare function shellPackageJson(params: {
|
|
3
|
+
scope: string;
|
|
4
|
+
moduleName: string;
|
|
5
|
+
preset: CliPreset;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function shellTsconfig(): string;
|
|
8
|
+
export declare function shellViteConfig(params: {
|
|
9
|
+
preset: CliPreset;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function shellIndexHtml(params: {
|
|
12
|
+
projectName: string;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function shellAuthStore(params: {
|
|
15
|
+
scope: string;
|
|
16
|
+
}): string;
|
|
17
|
+
export declare function shellConfigStore(params: {
|
|
18
|
+
scope: string;
|
|
19
|
+
appName: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function shellHttpClient(): string;
|
|
22
|
+
export declare function shellHome(params: {
|
|
23
|
+
scope: string;
|
|
24
|
+
}): string;
|
|
25
|
+
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/templates/shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;CACnB,GAAG,MAAM,CA0CT;AAED,wBAAgB,aAAa,IAAI,MAAM,CAYtC;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG,MAAM,CAgBrE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAkBtE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA6BhE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAUnF;AAED,wBAAgB,eAAe,IAAI,MAAM,CAgBxC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAmB3D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export function shellPackageJson(params) {
|
|
2
|
+
const { core, runtime, router, routerVersion } = params.preset.packages;
|
|
3
|
+
return JSON.stringify({
|
|
4
|
+
name: "shell",
|
|
5
|
+
version: "0.1.0",
|
|
6
|
+
private: true,
|
|
7
|
+
type: "module",
|
|
8
|
+
scripts: {
|
|
9
|
+
dev: "vite",
|
|
10
|
+
build: "vite build",
|
|
11
|
+
preview: "vite preview",
|
|
12
|
+
},
|
|
13
|
+
dependencies: {
|
|
14
|
+
"@modular-react/core": "^1.0.0",
|
|
15
|
+
"@modular-react/react": "^1.0.0",
|
|
16
|
+
[core]: "^2.0.0",
|
|
17
|
+
[runtime]: "^2.0.0",
|
|
18
|
+
[`${params.scope}/app-shared`]: "workspace:*",
|
|
19
|
+
[`${params.scope}/${params.moduleName}-module`]: "workspace:*",
|
|
20
|
+
"@lokalise/frontend-http-client": "^7.0.0",
|
|
21
|
+
wretch: "^2.11.0",
|
|
22
|
+
"@tanstack/react-query": "^5.95.0",
|
|
23
|
+
[router]: routerVersion,
|
|
24
|
+
react: "^19.0.0",
|
|
25
|
+
"react-dom": "^19.0.0",
|
|
26
|
+
zustand: "^5.0.0",
|
|
27
|
+
},
|
|
28
|
+
devDependencies: {
|
|
29
|
+
"@rolldown/plugin-babel": "^0.2.2",
|
|
30
|
+
"@types/react": "^19.0.0",
|
|
31
|
+
"@types/react-dom": "^19.0.0",
|
|
32
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
33
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
34
|
+
typescript: "^6.0.2",
|
|
35
|
+
vite: "^8.0.3",
|
|
36
|
+
},
|
|
37
|
+
}, null, 2);
|
|
38
|
+
}
|
|
39
|
+
export function shellTsconfig() {
|
|
40
|
+
return JSON.stringify({
|
|
41
|
+
extends: "../tsconfig.base.json",
|
|
42
|
+
include: ["src"],
|
|
43
|
+
compilerOptions: {
|
|
44
|
+
noEmit: true,
|
|
45
|
+
},
|
|
46
|
+
}, null, 2);
|
|
47
|
+
}
|
|
48
|
+
export function shellViteConfig(params) {
|
|
49
|
+
const dedupeList = params.preset.templates.shellViteDedupe.map((s) => `'${s}'`).join(", ");
|
|
50
|
+
return `import { defineConfig } from 'vite'
|
|
51
|
+
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
|
52
|
+
import babel from '@rolldown/plugin-babel'
|
|
53
|
+
|
|
54
|
+
export default defineConfig({
|
|
55
|
+
plugins: [
|
|
56
|
+
react(),
|
|
57
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
58
|
+
],
|
|
59
|
+
resolve: {
|
|
60
|
+
dedupe: [${dedupeList}],
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
export function shellIndexHtml(params) {
|
|
66
|
+
return `<!doctype html>
|
|
67
|
+
<html lang="en">
|
|
68
|
+
<head>
|
|
69
|
+
<meta charset="UTF-8" />
|
|
70
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
71
|
+
<title>${params.projectName}</title>
|
|
72
|
+
<style>
|
|
73
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
74
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #1a1a2e; }
|
|
75
|
+
</style>
|
|
76
|
+
</head>
|
|
77
|
+
<body>
|
|
78
|
+
<div id="root"></div>
|
|
79
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
80
|
+
</body>
|
|
81
|
+
</html>
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
export function shellAuthStore(params) {
|
|
85
|
+
return `import { createStore } from 'zustand/vanilla'
|
|
86
|
+
import type { AuthStore } from '${params.scope}/app-shared'
|
|
87
|
+
|
|
88
|
+
export const authStore = createStore<AuthStore>((set) => ({
|
|
89
|
+
user: null,
|
|
90
|
+
token: null,
|
|
91
|
+
isAuthenticated: false,
|
|
92
|
+
|
|
93
|
+
login: async (credentials) => {
|
|
94
|
+
// TODO: Replace with real API call
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
96
|
+
set({
|
|
97
|
+
user: {
|
|
98
|
+
id: 'usr-001',
|
|
99
|
+
name: 'Demo User',
|
|
100
|
+
email: credentials.email,
|
|
101
|
+
role: 'admin',
|
|
102
|
+
},
|
|
103
|
+
token: 'mock-jwt-token',
|
|
104
|
+
isAuthenticated: true,
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
logout: () => {
|
|
109
|
+
set({ user: null, token: null, isAuthenticated: false })
|
|
110
|
+
},
|
|
111
|
+
}))
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
export function shellConfigStore(params) {
|
|
115
|
+
return `import { createStore } from 'zustand/vanilla'
|
|
116
|
+
import type { ConfigStore } from '${params.scope}/app-shared'
|
|
117
|
+
|
|
118
|
+
export const configStore = createStore<ConfigStore>()(() => ({
|
|
119
|
+
apiBaseUrl: 'http://localhost:3000/api',
|
|
120
|
+
environment: 'dev' as const,
|
|
121
|
+
appName: '${params.appName}',
|
|
122
|
+
}))
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
export function shellHttpClient() {
|
|
126
|
+
return `import wretch from 'wretch'
|
|
127
|
+
import { authStore } from '../stores/auth.js'
|
|
128
|
+
import { configStore } from '../stores/config.js'
|
|
129
|
+
|
|
130
|
+
export const httpClient = wretch()
|
|
131
|
+
.defer((w) => {
|
|
132
|
+
const { apiBaseUrl } = configStore.getState()
|
|
133
|
+
const { token } = authStore.getState()
|
|
134
|
+
let instance = w.url(apiBaseUrl)
|
|
135
|
+
if (token) {
|
|
136
|
+
instance = instance.auth(\`Bearer \${token}\`)
|
|
137
|
+
}
|
|
138
|
+
return instance
|
|
139
|
+
})
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
export function shellHome(params) {
|
|
143
|
+
return `import { useStore } from '${params.scope}/app-shared'
|
|
144
|
+
|
|
145
|
+
export function Home() {
|
|
146
|
+
const appName = useStore('config', (s) => s.appName)
|
|
147
|
+
const isAuthenticated = useStore('auth', (s) => s.isAuthenticated)
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div>
|
|
151
|
+
<h2>Welcome to {appName}</h2>
|
|
152
|
+
<p>
|
|
153
|
+
{isAuthenticated
|
|
154
|
+
? 'Use the sidebar to navigate between modules.'
|
|
155
|
+
: 'Click "Login as Demo User" to get started.'}
|
|
156
|
+
</p>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/templates/shell.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,MAIhC;IACC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IAExE,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,GAAG,EAAE,MAAM;YACX,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,cAAc;SACxB;QACD,YAAY,EAAE;YACZ,qBAAqB,EAAE,QAAQ;YAC/B,sBAAsB,EAAE,QAAQ;YAChC,CAAC,IAAI,CAAC,EAAE,QAAQ;YAChB,CAAC,OAAO,CAAC,EAAE,QAAQ;YACnB,CAAC,GAAG,MAAM,CAAC,KAAK,aAAa,CAAC,EAAE,aAAa;YAC7C,CAAC,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,SAAS,CAAC,EAAE,aAAa;YAC9D,gCAAgC,EAAE,QAAQ;YAC1C,MA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AKlC,MAAM,CAAC,OAAO;;CAE3B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO;;;;;;;;;;;;;;CAcR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAyB;IACjD,OAAO,6BAA6B,MAAM,CAAC,KAAK;;;;;;;;;;;;;;;;;CAiBjD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/templates/store.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAQT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function storeFile(params) {
|
|
2
|
+
return `import { createStore } from 'zustand/vanilla'
|
|
3
|
+
import type { ${params.interfaceName} } from '${params.scope}/app-shared'
|
|
4
|
+
|
|
5
|
+
export const ${params.exportName} = createStore<${params.interfaceName}>()(() => ({
|
|
6
|
+
// TODO: Add initial state
|
|
7
|
+
}))
|
|
8
|
+
`;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/templates/store.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,MAIzB;IACC,OAAO;gBACO,MAAM,CAAC,aAAa,YAAY,MAAM,CAAC,KAAK;;eAE7C,MAAM,CAAC,UAAU,kBAAkB,MAAM,CAAC,aAAa;;;CAGrE,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function rootPackageJson(params: {
|
|
2
|
+
name: string;
|
|
3
|
+
}): string;
|
|
4
|
+
export declare function pnpmWorkspace(): string;
|
|
5
|
+
export declare function tsconfigBase(): string;
|
|
6
|
+
export declare function tsconfigRoot(): string;
|
|
7
|
+
export declare function gitignore(): string;
|
|
8
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/templates/workspace.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAoBhE;AAED,wBAAgB,aAAa,IAAI,MAAM,CAUtC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAsBrC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,SAAS,IAAI,MAAM,CAMlC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function rootPackageJson(params) {
|
|
2
|
+
return JSON.stringify({
|
|
3
|
+
name: params.name,
|
|
4
|
+
version: "1.0.0",
|
|
5
|
+
private: true,
|
|
6
|
+
scripts: {
|
|
7
|
+
build: "pnpm -r run build",
|
|
8
|
+
dev: "pnpm --filter shell dev",
|
|
9
|
+
test: "vitest run",
|
|
10
|
+
typecheck: "tsc --build",
|
|
11
|
+
},
|
|
12
|
+
devDependencies: {
|
|
13
|
+
typescript: "^6.0.2",
|
|
14
|
+
vitest: "^4.1.0",
|
|
15
|
+
},
|
|
16
|
+
}, null, 2);
|
|
17
|
+
}
|
|
18
|
+
export function pnpmWorkspace() {
|
|
19
|
+
return `packages:
|
|
20
|
+
- app-shared
|
|
21
|
+
- shell
|
|
22
|
+
- modules/*
|
|
23
|
+
- journeys/*
|
|
24
|
+
|
|
25
|
+
onlyBuiltDependencies:
|
|
26
|
+
- esbuild
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
export function tsconfigBase() {
|
|
30
|
+
return JSON.stringify({
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
target: "ES2022",
|
|
33
|
+
module: "ES2022",
|
|
34
|
+
moduleResolution: "bundler",
|
|
35
|
+
esModuleInterop: true,
|
|
36
|
+
forceConsistentCasingInFileNames: true,
|
|
37
|
+
strict: true,
|
|
38
|
+
skipLibCheck: true,
|
|
39
|
+
declaration: true,
|
|
40
|
+
declarationMap: true,
|
|
41
|
+
sourceMap: true,
|
|
42
|
+
jsx: "react-jsx",
|
|
43
|
+
isolatedModules: true,
|
|
44
|
+
verbatimModuleSyntax: true,
|
|
45
|
+
},
|
|
46
|
+
}, null, 2);
|
|
47
|
+
}
|
|
48
|
+
export function tsconfigRoot() {
|
|
49
|
+
return JSON.stringify({ files: [], references: [] }, null, 2);
|
|
50
|
+
}
|
|
51
|
+
export function gitignore() {
|
|
52
|
+
return `node_modules/
|
|
53
|
+
dist/
|
|
54
|
+
*.tsbuildinfo
|
|
55
|
+
.vite/
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/templates/workspace.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,MAAwB;IACtD,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,KAAK,EAAE,mBAAmB;YAC1B,GAAG,EAAE,yBAAyB;YAC9B,IAAI,EAAE,YAAY;YAClB,SAAS,EAAE,aAAa;SACzB;QACD,eAAe,EAAE;YACf,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,QAAQ;SACjB;KACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,eAAe,EAAE;YACf,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,QAAQ;YAChB,gBAAgB,EAAE,SAAS;YAC3B,eAAe,EAAE,IAAI;YACrB,gCAAgC,EAAE,IAAI;YACtC,MAAM,EAAE,IAAI;YACZ,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,WAAW;YAChB,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;SAC3B;KACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO;;;;CAIR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-scope.d.ts","sourceRoot":"","sources":["../../src/utils/detect-scope.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAavD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "pathe";
|
|
3
|
+
export function detectScope(projectRoot) {
|
|
4
|
+
const pkgPath = resolve(projectRoot, "app-shared", "package.json");
|
|
5
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
6
|
+
const name = pkg.name;
|
|
7
|
+
const match = name.match(/^(@[^/]+)\//);
|
|
8
|
+
if (!match) {
|
|
9
|
+
throw new Error(`Could not detect scope from app-shared package name: "${name}". Expected format: @scope/app-shared`);
|
|
10
|
+
}
|
|
11
|
+
return match[1];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=detect-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-scope.js","sourceRoot":"","sources":["../../src/utils/detect-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAW,GAAG,CAAC,IAAI,CAAC;IAE9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,uCAAuC,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
/**
|
|
3
|
+
* Run a `@clack/prompts` text prompt and unwrap the result. Exits the
|
|
4
|
+
* process cleanly on Ctrl-C / cancellation so callers don't have to
|
|
5
|
+
* shepherd the cancel symbol through every prompt site.
|
|
6
|
+
*/
|
|
7
|
+
export declare function promptText(options: Parameters<typeof p.text>[0]): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Bail out cleanly when the user hits Ctrl-C on a prompt. Use after any
|
|
10
|
+
* prompt whose result is consumed without going through {@link promptText}
|
|
11
|
+
* (e.g. when the value is conditionally derived from a flag fallback).
|
|
12
|
+
*/
|
|
13
|
+
export declare function exitIfCancelled(value: unknown): void;
|
|
14
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAOvF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAKpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
/**
|
|
3
|
+
* Run a `@clack/prompts` text prompt and unwrap the result. Exits the
|
|
4
|
+
* process cleanly on Ctrl-C / cancellation so callers don't have to
|
|
5
|
+
* shepherd the cancel symbol through every prompt site.
|
|
6
|
+
*/
|
|
7
|
+
export async function promptText(options) {
|
|
8
|
+
const value = await p.text(options);
|
|
9
|
+
if (p.isCancel(value)) {
|
|
10
|
+
p.cancel("Cancelled");
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bail out cleanly when the user hits Ctrl-C on a prompt. Use after any
|
|
17
|
+
* prompt whose result is consumed without going through {@link promptText}
|
|
18
|
+
* (e.g. when the value is conditionally derived from a flag fallback).
|
|
19
|
+
*/
|
|
20
|
+
export function exitIfCancelled(value) {
|
|
21
|
+
if (p.isCancel(value)) {
|
|
22
|
+
p.cancel("Cancelled");
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAqC;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ProjectRoot {
|
|
2
|
+
readonly root: string;
|
|
3
|
+
readonly appSharedDir: string;
|
|
4
|
+
readonly shellDir: string;
|
|
5
|
+
readonly modulesDir: string;
|
|
6
|
+
readonly journeysDir: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveProject(from?: string): ProjectRoot;
|
|
9
|
+
//# sourceMappingURL=resolve-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-project.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,cAAc,CAAC,IAAI,GAAE,MAAsB,GAAG,WAAW,CAsBxE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve, dirname } from "pathe";
|
|
3
|
+
export function resolveProject(from = process.cwd()) {
|
|
4
|
+
let current = resolve(from);
|
|
5
|
+
while (true) {
|
|
6
|
+
if (existsSync(resolve(current, "pnpm-workspace.yaml"))) {
|
|
7
|
+
return {
|
|
8
|
+
root: current,
|
|
9
|
+
appSharedDir: resolve(current, "app-shared"),
|
|
10
|
+
shellDir: resolve(current, "shell"),
|
|
11
|
+
modulesDir: resolve(current, "modules"),
|
|
12
|
+
journeysDir: resolve(current, "journeys"),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const parent = dirname(current);
|
|
16
|
+
if (parent === current) {
|
|
17
|
+
throw new Error("Could not find pnpm-workspace.yaml. Are you inside a modular-react project?");
|
|
18
|
+
}
|
|
19
|
+
current = parent;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=resolve-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project.js","sourceRoot":"","sources":["../../src/utils/resolve-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAUzC,MAAM,UAAU,cAAc,CAAC,OAAe,OAAO,CAAC,GAAG,EAAE;IACzD,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC;gBAC5C,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;gBACnC,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;gBACvC,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;aAC1C,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC"}
|