workspace-manager-cli 1.0.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/README.md +339 -0
- package/dist/build.d.ts +19 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +384 -0
- package/dist/build.js.map +1 -0
- package/dist/bundler/build-bundler.d.ts +9 -0
- package/dist/bundler/build-bundler.d.ts.map +1 -0
- package/dist/bundler/build-bundler.js +218 -0
- package/dist/bundler/build-bundler.js.map +1 -0
- package/dist/bundler/package-merger.d.ts +21 -0
- package/dist/bundler/package-merger.d.ts.map +1 -0
- package/dist/bundler/package-merger.js +192 -0
- package/dist/bundler/package-merger.js.map +1 -0
- package/dist/bundler/vite-generator.d.ts +14 -0
- package/dist/bundler/vite-generator.d.ts.map +1 -0
- package/dist/bundler/vite-generator.js +186 -0
- package/dist/bundler/vite-generator.js.map +1 -0
- package/dist/config.d.ts +250 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +268 -0
- package/dist/config.js.map +1 -0
- package/dist/copy.d.ts +9 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +56 -0
- package/dist/copy.js.map +1 -0
- package/dist/git.d.ts +76 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +377 -0
- package/dist/git.js.map +1 -0
- package/dist/index-update-base.d.ts +2 -0
- package/dist/index-update-base.d.ts.map +1 -0
- package/dist/index-update-base.js +76 -0
- package/dist/index-update-base.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +626 -0
- package/dist/index.js.map +1 -0
- package/dist/lock.d.ts +39 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +91 -0
- package/dist/lock.js.map +1 -0
- package/dist/logger.d.ts +42 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +90 -0
- package/dist/logger.js.map +1 -0
- package/dist/status.d.ts +23 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +158 -0
- package/dist/status.js.map +1 -0
- package/package.json +47 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Logger } from "./logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Project types:
|
|
5
|
+
* - core-custom: Remote core + local custom (custom overlays on core)
|
|
6
|
+
* - base-core: Remote base + local core (core replaces base/src/core)
|
|
7
|
+
* - base-core-custom: Remote base + remote core + local custom (core replaces base/src/core, custom overlays on core)
|
|
8
|
+
*/
|
|
9
|
+
export type ProjectType = "core-custom" | "base-core" | "base-core-custom";
|
|
10
|
+
/**
|
|
11
|
+
* Zod schema for base repository config (always remote)
|
|
12
|
+
*/
|
|
13
|
+
export declare const BaseConfigSchema: z.ZodObject<{
|
|
14
|
+
name: z.ZodDefault<z.ZodString>;
|
|
15
|
+
url: z.ZodString;
|
|
16
|
+
ref: z.ZodDefault<z.ZodString>;
|
|
17
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
name: string;
|
|
20
|
+
url: string;
|
|
21
|
+
ref: string;
|
|
22
|
+
hash?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
url: string;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
ref?: string | undefined;
|
|
27
|
+
hash?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Zod schema for core config (can be remote or local)
|
|
31
|
+
*/
|
|
32
|
+
export declare const CoreConfigSchema: z.ZodObject<{
|
|
33
|
+
name: z.ZodDefault<z.ZodString>;
|
|
34
|
+
url: z.ZodOptional<z.ZodString>;
|
|
35
|
+
ref: z.ZodDefault<z.ZodString>;
|
|
36
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
37
|
+
path: z.ZodDefault<z.ZodString>;
|
|
38
|
+
srcPath: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
name: string;
|
|
41
|
+
ref: string;
|
|
42
|
+
path: string;
|
|
43
|
+
url?: string | undefined;
|
|
44
|
+
hash?: string | undefined;
|
|
45
|
+
srcPath?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
ref?: string | undefined;
|
|
50
|
+
hash?: string | undefined;
|
|
51
|
+
path?: string | undefined;
|
|
52
|
+
srcPath?: string | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Zod schema for custom config (always local)
|
|
56
|
+
*/
|
|
57
|
+
export declare const CustomConfigSchema: z.ZodObject<{
|
|
58
|
+
path: z.ZodDefault<z.ZodString>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
path: string;
|
|
61
|
+
}, {
|
|
62
|
+
path?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const InstallConfigSchema: z.ZodObject<{
|
|
65
|
+
command: z.ZodDefault<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
command: string;
|
|
68
|
+
}, {
|
|
69
|
+
command?: string | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* New unified workspace config schema
|
|
73
|
+
*/
|
|
74
|
+
export declare const WorkspaceConfigSchemaNew: z.ZodObject<{
|
|
75
|
+
projectType: z.ZodOptional<z.ZodEnum<["core-custom", "base-core", "base-core-custom"]>>;
|
|
76
|
+
base: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
name: z.ZodDefault<z.ZodString>;
|
|
78
|
+
url: z.ZodString;
|
|
79
|
+
ref: z.ZodDefault<z.ZodString>;
|
|
80
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
name: string;
|
|
83
|
+
url: string;
|
|
84
|
+
ref: string;
|
|
85
|
+
hash?: string | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
url: string;
|
|
88
|
+
name?: string | undefined;
|
|
89
|
+
ref?: string | undefined;
|
|
90
|
+
hash?: string | undefined;
|
|
91
|
+
}>>;
|
|
92
|
+
core: z.ZodDefault<z.ZodObject<{
|
|
93
|
+
name: z.ZodDefault<z.ZodString>;
|
|
94
|
+
url: z.ZodOptional<z.ZodString>;
|
|
95
|
+
ref: z.ZodDefault<z.ZodString>;
|
|
96
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
97
|
+
path: z.ZodDefault<z.ZodString>;
|
|
98
|
+
srcPath: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
name: string;
|
|
101
|
+
ref: string;
|
|
102
|
+
path: string;
|
|
103
|
+
url?: string | undefined;
|
|
104
|
+
hash?: string | undefined;
|
|
105
|
+
srcPath?: string | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
name?: string | undefined;
|
|
108
|
+
url?: string | undefined;
|
|
109
|
+
ref?: string | undefined;
|
|
110
|
+
hash?: string | undefined;
|
|
111
|
+
path?: string | undefined;
|
|
112
|
+
srcPath?: string | undefined;
|
|
113
|
+
}>>;
|
|
114
|
+
custom: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
path: z.ZodDefault<z.ZodString>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
path: string;
|
|
118
|
+
}, {
|
|
119
|
+
path?: string | undefined;
|
|
120
|
+
}>>;
|
|
121
|
+
install: z.ZodDefault<z.ZodObject<{
|
|
122
|
+
command: z.ZodDefault<z.ZodString>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
command: string;
|
|
125
|
+
}, {
|
|
126
|
+
command?: string | undefined;
|
|
127
|
+
}>>;
|
|
128
|
+
excludes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
core: {
|
|
131
|
+
name: string;
|
|
132
|
+
ref: string;
|
|
133
|
+
path: string;
|
|
134
|
+
url?: string | undefined;
|
|
135
|
+
hash?: string | undefined;
|
|
136
|
+
srcPath?: string | undefined;
|
|
137
|
+
};
|
|
138
|
+
install: {
|
|
139
|
+
command: string;
|
|
140
|
+
};
|
|
141
|
+
base?: {
|
|
142
|
+
name: string;
|
|
143
|
+
url: string;
|
|
144
|
+
ref: string;
|
|
145
|
+
hash?: string | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
custom?: {
|
|
148
|
+
path: string;
|
|
149
|
+
} | undefined;
|
|
150
|
+
projectType?: "core-custom" | "base-core" | "base-core-custom" | undefined;
|
|
151
|
+
excludes?: string[] | undefined;
|
|
152
|
+
}, {
|
|
153
|
+
base?: {
|
|
154
|
+
url: string;
|
|
155
|
+
name?: string | undefined;
|
|
156
|
+
ref?: string | undefined;
|
|
157
|
+
hash?: string | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
core?: {
|
|
160
|
+
name?: string | undefined;
|
|
161
|
+
url?: string | undefined;
|
|
162
|
+
ref?: string | undefined;
|
|
163
|
+
hash?: string | undefined;
|
|
164
|
+
path?: string | undefined;
|
|
165
|
+
srcPath?: string | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
custom?: {
|
|
168
|
+
path?: string | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
projectType?: "core-custom" | "base-core" | "base-core-custom" | undefined;
|
|
171
|
+
install?: {
|
|
172
|
+
command?: string | undefined;
|
|
173
|
+
} | undefined;
|
|
174
|
+
excludes?: string[] | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
export type BaseConfig = z.infer<typeof BaseConfigSchema>;
|
|
177
|
+
export type CoreConfig = z.infer<typeof CoreConfigSchema>;
|
|
178
|
+
export type CustomConfig = z.infer<typeof CustomConfigSchema>;
|
|
179
|
+
export type InstallConfig = z.infer<typeof InstallConfigSchema>;
|
|
180
|
+
export type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchemaNew>;
|
|
181
|
+
/**
|
|
182
|
+
* Resolved paths for the workspace configuration
|
|
183
|
+
*/
|
|
184
|
+
export interface ResolvedConfig extends WorkspaceConfig {
|
|
185
|
+
projectRoot: string;
|
|
186
|
+
projectType: ProjectType;
|
|
187
|
+
workspacePath: string;
|
|
188
|
+
baseCachePath?: string;
|
|
189
|
+
coreCachePath?: string;
|
|
190
|
+
coreLocalPath?: string;
|
|
191
|
+
coreMountPath: string;
|
|
192
|
+
coreSrcPath?: string;
|
|
193
|
+
customPath?: string;
|
|
194
|
+
customMountPath: string;
|
|
195
|
+
cachePath: string;
|
|
196
|
+
customDir?: string;
|
|
197
|
+
coreDir?: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Detect project type based on config content
|
|
201
|
+
* If projectType is explicitly set, use it; otherwise auto-detect
|
|
202
|
+
*/
|
|
203
|
+
export declare function detectProjectType(config: WorkspaceConfig): ProjectType;
|
|
204
|
+
/**
|
|
205
|
+
* Find project root by looking for workspace.config.json or workspace.config.js
|
|
206
|
+
*/
|
|
207
|
+
export declare function findProjectRoot(startDir?: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Load configuration from workspace.config.json or workspace.config.js
|
|
210
|
+
*/
|
|
211
|
+
export declare function loadConfig(projectRoot?: string): Promise<ResolvedConfig>;
|
|
212
|
+
export interface HashUpdates {
|
|
213
|
+
baseHash?: string;
|
|
214
|
+
baseRef?: string;
|
|
215
|
+
coreHash?: string;
|
|
216
|
+
coreRef?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Persist the latest git hashes and refs into workspace.config.json (best-effort)
|
|
220
|
+
*/
|
|
221
|
+
export declare function persistHashesToWorkspaceConfig(config: ResolvedConfig, updates: HashUpdates, logger?: Logger): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Get project type description for display
|
|
224
|
+
*/
|
|
225
|
+
export declare function getProjectTypeDescription(type: ProjectType): string;
|
|
226
|
+
/**
|
|
227
|
+
* Get core info safely (for display purposes)
|
|
228
|
+
*/
|
|
229
|
+
export declare function getCoreInfo(config: ResolvedConfig): {
|
|
230
|
+
name: string;
|
|
231
|
+
url?: string;
|
|
232
|
+
ref?: string;
|
|
233
|
+
source?: string;
|
|
234
|
+
} | null;
|
|
235
|
+
/**
|
|
236
|
+
* Get base info safely
|
|
237
|
+
*/
|
|
238
|
+
export declare function getBaseInfo(config: ResolvedConfig): {
|
|
239
|
+
name: string;
|
|
240
|
+
url: string;
|
|
241
|
+
ref: string;
|
|
242
|
+
} | null;
|
|
243
|
+
/**
|
|
244
|
+
* Get custom info safely
|
|
245
|
+
*/
|
|
246
|
+
export declare function getCustomInfo(config: ResolvedConfig): {
|
|
247
|
+
path: string;
|
|
248
|
+
mount: string;
|
|
249
|
+
} | null;
|
|
250
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAU3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;EAE7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;EAE9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASnC,CAAC;AAEH,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,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CASnE;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASnD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUxC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema for base repository config (always remote)
|
|
7
|
+
*/
|
|
8
|
+
export const BaseConfigSchema = z.object({
|
|
9
|
+
name: z.string().default("base"),
|
|
10
|
+
url: z.string(),
|
|
11
|
+
ref: z.string().default("main"),
|
|
12
|
+
hash: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Zod schema for core config (can be remote or local)
|
|
16
|
+
*/
|
|
17
|
+
export const CoreConfigSchema = z.object({
|
|
18
|
+
// Remote properties
|
|
19
|
+
name: z.string().default("core"),
|
|
20
|
+
url: z.string().optional(),
|
|
21
|
+
ref: z.string().default("main"),
|
|
22
|
+
hash: z.string().optional(),
|
|
23
|
+
// Local properties
|
|
24
|
+
path: z.string().default("core"),
|
|
25
|
+
// Optional explicit source path (absolute or relative to project root)
|
|
26
|
+
srcPath: z.string().optional(),
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Zod schema for custom config (always local)
|
|
30
|
+
*/
|
|
31
|
+
export const CustomConfigSchema = z.object({
|
|
32
|
+
path: z.string().default("custom"),
|
|
33
|
+
});
|
|
34
|
+
export const InstallConfigSchema = z.object({
|
|
35
|
+
command: z.string().default("npm install"),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* New unified workspace config schema
|
|
39
|
+
*/
|
|
40
|
+
export const WorkspaceConfigSchemaNew = z.object({
|
|
41
|
+
projectType: z
|
|
42
|
+
.enum(["core-custom", "base-core", "base-core-custom"])
|
|
43
|
+
.optional(),
|
|
44
|
+
base: BaseConfigSchema.optional(),
|
|
45
|
+
core: CoreConfigSchema.default({}),
|
|
46
|
+
custom: CustomConfigSchema.optional(),
|
|
47
|
+
install: InstallConfigSchema.default({}),
|
|
48
|
+
excludes: z.array(z.string()).optional(),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Detect project type based on config content
|
|
52
|
+
* If projectType is explicitly set, use it; otherwise auto-detect
|
|
53
|
+
*/
|
|
54
|
+
export function detectProjectType(config) {
|
|
55
|
+
// If explicitly set, use it
|
|
56
|
+
if (config.projectType) {
|
|
57
|
+
return config.projectType;
|
|
58
|
+
}
|
|
59
|
+
// Otherwise, auto-detect (legacy behavior)
|
|
60
|
+
const hasBase = !!config.base;
|
|
61
|
+
const coreIsRemote = !!config.core.url;
|
|
62
|
+
const hasCustom = !!config.custom;
|
|
63
|
+
if (hasBase && coreIsRemote && hasCustom) {
|
|
64
|
+
return "base-core-custom";
|
|
65
|
+
}
|
|
66
|
+
else if (hasBase && !coreIsRemote) {
|
|
67
|
+
return "base-core";
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return "core-custom";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Find project root by looking for workspace.config.json or workspace.config.js
|
|
75
|
+
*/
|
|
76
|
+
export function findProjectRoot(startDir = process.cwd()) {
|
|
77
|
+
const currentDir = path.resolve(startDir);
|
|
78
|
+
// Only check current directory, don't traverse up parent directories
|
|
79
|
+
if (fs.existsSync(path.join(currentDir, "workspace.config.json")) ||
|
|
80
|
+
fs.existsSync(path.join(currentDir, "workspace.config.js"))) {
|
|
81
|
+
return currentDir;
|
|
82
|
+
}
|
|
83
|
+
throw new Error("Could not find workspace.config.json or workspace.config.js in current directory");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Load configuration from workspace.config.json or workspace.config.js
|
|
87
|
+
*/
|
|
88
|
+
export async function loadConfig(projectRoot) {
|
|
89
|
+
const root = projectRoot || findProjectRoot();
|
|
90
|
+
const jsonPath = path.join(root, "workspace.config.json");
|
|
91
|
+
const jsPath = path.join(root, "workspace.config.js");
|
|
92
|
+
let rawConfig;
|
|
93
|
+
if (fs.existsSync(jsonPath)) {
|
|
94
|
+
try {
|
|
95
|
+
const content = await fs.readFile(jsonPath, "utf-8");
|
|
96
|
+
rawConfig = JSON.parse(content);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
throw new Error(`Failed to parse workspace.config.json: ${err instanceof Error ? err.message : err}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (fs.existsSync(jsPath)) {
|
|
103
|
+
try {
|
|
104
|
+
const fileUrl = pathToFileURL(jsPath).href;
|
|
105
|
+
const module = await import(fileUrl);
|
|
106
|
+
rawConfig = module.default || module;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
throw new Error(`Failed to load workspace.config.js: ${err instanceof Error ? err.message : err}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new Error(`No configuration file found in ${root}`);
|
|
114
|
+
}
|
|
115
|
+
let config;
|
|
116
|
+
// Validate against the new schema
|
|
117
|
+
const result = WorkspaceConfigSchemaNew.safeParse(rawConfig);
|
|
118
|
+
if (!result.success) {
|
|
119
|
+
const errors = result.error.issues
|
|
120
|
+
.map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`)
|
|
121
|
+
.join("\n");
|
|
122
|
+
throw new Error(`Configuration validation failed:\n${errors}`);
|
|
123
|
+
}
|
|
124
|
+
config = result.data;
|
|
125
|
+
const projectType = detectProjectType(config);
|
|
126
|
+
// Reject deprecated workspaceDir property strictly
|
|
127
|
+
if (rawConfig &&
|
|
128
|
+
typeof rawConfig === "object" &&
|
|
129
|
+
"workspaceDir" in rawConfig) {
|
|
130
|
+
throw new Error('The "workspaceDir" setting is no longer supported. The workspace directory is fixed to "workspace". Please remove "workspaceDir" from your configuration.');
|
|
131
|
+
}
|
|
132
|
+
// Resolve workspace path (fixed)
|
|
133
|
+
const workspacePath = path.resolve(root, "workspace");
|
|
134
|
+
// Resolve mount paths (fixed)
|
|
135
|
+
const coreMountPath = path.join(workspacePath, "src", "core");
|
|
136
|
+
const customMountPath = config.custom
|
|
137
|
+
? path.join(workspacePath, "src", "core", "custom")
|
|
138
|
+
: "";
|
|
139
|
+
// Initialize resolved config
|
|
140
|
+
const resolved = {
|
|
141
|
+
...config,
|
|
142
|
+
projectRoot: root,
|
|
143
|
+
projectType,
|
|
144
|
+
workspacePath,
|
|
145
|
+
coreMountPath,
|
|
146
|
+
customMountPath,
|
|
147
|
+
cachePath: "", // Will be set below
|
|
148
|
+
customDir: config.custom?.path,
|
|
149
|
+
coreDir: config.core.path,
|
|
150
|
+
};
|
|
151
|
+
// Resolve custom path if enabled
|
|
152
|
+
if (config.custom) {
|
|
153
|
+
resolved.customPath = path.resolve(root, config.custom.path);
|
|
154
|
+
}
|
|
155
|
+
// Resolve base cache path if enabled
|
|
156
|
+
if (config.base && config.base.url) {
|
|
157
|
+
resolved.baseCachePath = path.join(root, ".wmc-cache", config.base.name);
|
|
158
|
+
resolved.cachePath = resolved.baseCachePath;
|
|
159
|
+
}
|
|
160
|
+
// Resolve core paths based on type
|
|
161
|
+
if (config.core.url) {
|
|
162
|
+
resolved.coreCachePath = path.join(root, ".wmc-cache", config.core.name);
|
|
163
|
+
if (!resolved.cachePath) {
|
|
164
|
+
resolved.cachePath = resolved.coreCachePath;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
resolved.coreLocalPath = path.resolve(root, config.core.path);
|
|
169
|
+
}
|
|
170
|
+
// Resolve explicit core srcPath if provided
|
|
171
|
+
if (config.core && config.core.srcPath) {
|
|
172
|
+
resolved.coreSrcPath = path.resolve(root, config.core.srcPath);
|
|
173
|
+
}
|
|
174
|
+
return resolved;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Persist the latest git hashes and refs into workspace.config.json (best-effort)
|
|
178
|
+
*/
|
|
179
|
+
export async function persistHashesToWorkspaceConfig(config, updates, logger) {
|
|
180
|
+
const jsonPath = path.join(config.projectRoot, "workspace.config.json");
|
|
181
|
+
if (!(await fs.pathExists(jsonPath))) {
|
|
182
|
+
logger?.debug?.("workspace.config.json not found; skipping hash persistence");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const content = await fs.readFile(jsonPath, "utf-8");
|
|
187
|
+
const parsed = JSON.parse(content);
|
|
188
|
+
if (updates.baseHash || updates.baseRef) {
|
|
189
|
+
parsed.base = parsed.base || {};
|
|
190
|
+
if (updates.baseHash) {
|
|
191
|
+
parsed.base.hash = updates.baseHash;
|
|
192
|
+
}
|
|
193
|
+
if (updates.baseRef) {
|
|
194
|
+
parsed.base.ref = updates.baseRef;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (updates.coreHash || updates.coreRef) {
|
|
198
|
+
parsed.core = parsed.core || {};
|
|
199
|
+
if (updates.coreHash) {
|
|
200
|
+
parsed.core.hash = updates.coreHash;
|
|
201
|
+
}
|
|
202
|
+
if (updates.coreRef) {
|
|
203
|
+
parsed.core.ref = updates.coreRef;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const serialized = JSON.stringify(parsed, null, 2);
|
|
207
|
+
await fs.writeFile(jsonPath, `${serialized}\n`, "utf-8");
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
211
|
+
logger?.warn(`Failed to persist git hash/ref to workspace.config.json: ${message}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get project type description for display
|
|
216
|
+
*/
|
|
217
|
+
export function getProjectTypeDescription(type) {
|
|
218
|
+
switch (type) {
|
|
219
|
+
case "core-custom":
|
|
220
|
+
return "Remote core + Local custom";
|
|
221
|
+
case "base-core":
|
|
222
|
+
return "Remote base + Local core";
|
|
223
|
+
case "base-core-custom":
|
|
224
|
+
return "Remote base + Remote core + Local custom";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get core info safely (for display purposes)
|
|
229
|
+
*/
|
|
230
|
+
export function getCoreInfo(config) {
|
|
231
|
+
if (config.core) {
|
|
232
|
+
return {
|
|
233
|
+
name: config.core.name,
|
|
234
|
+
url: config.core.url,
|
|
235
|
+
ref: config.core.ref,
|
|
236
|
+
source: config.coreSrcPath,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get base info safely
|
|
243
|
+
*/
|
|
244
|
+
export function getBaseInfo(config) {
|
|
245
|
+
if (config.base && config.base.url) {
|
|
246
|
+
return {
|
|
247
|
+
name: config.base.name,
|
|
248
|
+
url: config.base.url,
|
|
249
|
+
ref: config.base.ref,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get custom info safely
|
|
256
|
+
*/
|
|
257
|
+
export function getCustomInfo(config) {
|
|
258
|
+
if (config.custom) {
|
|
259
|
+
return {
|
|
260
|
+
path: config.custom.path,
|
|
261
|
+
mount: path
|
|
262
|
+
.join(config.workspacePath, "src", "core", "custom")
|
|
263
|
+
.replace(/\\/g, "/"),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAWpC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,oBAAoB;IACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM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AI,CAAC,GAAG;SACrB,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB;IAEtB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;YACxB,KAAK,EAAE,IAAI;iBACR,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC;iBACnD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACvB,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/copy.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from "./logger.js";
|
|
2
|
+
export declare const DEFAULT_EXCLUDES: string[];
|
|
3
|
+
export declare function getEffectiveExcludes(userExcludes?: string[]): string[];
|
|
4
|
+
export declare function formatExcludes(userExcludes?: string[]): string;
|
|
5
|
+
/**
|
|
6
|
+
* Copy directory contents with exclusions
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyWithExcludes(src: string, dest: string, excludes: string[], logger: Logger, dryRun: boolean): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,eAAO,MAAM,gBAAgB,UAO5B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,YAAY,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAE1E;AAED,wBAAgB,cAAc,CAAC,YAAY,GAAE,MAAM,EAAO,GAAG,MAAM,CAGlE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,CAoCjB"}
|
package/dist/copy.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { globby } from "globby";
|
|
4
|
+
export const DEFAULT_EXCLUDES = [
|
|
5
|
+
".git",
|
|
6
|
+
".git/**",
|
|
7
|
+
"node_modules",
|
|
8
|
+
"node_modules/**",
|
|
9
|
+
".DS_Store",
|
|
10
|
+
"Thumbs.db",
|
|
11
|
+
];
|
|
12
|
+
export function getEffectiveExcludes(userExcludes = []) {
|
|
13
|
+
return [...DEFAULT_EXCLUDES, ...userExcludes];
|
|
14
|
+
}
|
|
15
|
+
export function formatExcludes(userExcludes = []) {
|
|
16
|
+
const arr = userExcludes.length > 0 ? userExcludes : [];
|
|
17
|
+
return arr.length > 0 ? arr.join(", ") : "(none)";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Copy directory contents with exclusions
|
|
21
|
+
*/
|
|
22
|
+
export async function copyWithExcludes(src, dest, excludes, logger, dryRun) {
|
|
23
|
+
if (!(await fs.pathExists(src))) {
|
|
24
|
+
logger.warn(`Source path does not exist: ${src}`);
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
const allExcludes = getEffectiveExcludes(excludes);
|
|
28
|
+
const files = await globby(["**/*"], {
|
|
29
|
+
cwd: src,
|
|
30
|
+
dot: true,
|
|
31
|
+
ignore: allExcludes,
|
|
32
|
+
onlyFiles: false,
|
|
33
|
+
markDirectories: true,
|
|
34
|
+
});
|
|
35
|
+
let copied = 0;
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
const srcPath = path.join(src, file);
|
|
38
|
+
const destPath = path.join(dest, file);
|
|
39
|
+
if (dryRun) {
|
|
40
|
+
logger.debug(`[dry-run] Copy: ${file}`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const stat = await fs.stat(srcPath);
|
|
44
|
+
if (stat.isDirectory()) {
|
|
45
|
+
await fs.ensureDir(destPath);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
await fs.ensureDir(path.dirname(destPath));
|
|
49
|
+
await fs.copy(srcPath, destPath, { overwrite: true });
|
|
50
|
+
copied++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return copied;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=copy.js.map
|
package/dist/copy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,SAAS;IACT,cAAc;IACd,iBAAiB;IACjB,WAAW;IACX,WAAW;CACZ,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,eAAyB,EAAE;IAC9D,OAAO,CAAC,GAAG,gBAAgB,EAAE,GAAG,YAAY,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,eAAyB,EAAE;IACxD,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAW,EACX,IAAY,EACZ,QAAkB,EAClB,MAAc,EACd,MAAe;IAEf,I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