@ghl-ai/aw 0.1.34-beta.6 → 0.1.34-beta.7
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/commands/pull.mjs +47 -6
- package/package.json +1 -1
package/commands/pull.mjs
CHANGED
|
@@ -34,7 +34,7 @@ export async function pullCommand(args) {
|
|
|
34
34
|
const dryRun = args['--dry-run'] === true;
|
|
35
35
|
const verbose = args['-v'] === true || args['--verbose'] === true;
|
|
36
36
|
const silent = args['--silent'] === true || args._silent === true;
|
|
37
|
-
|
|
37
|
+
let renameNamespace = args._renameNamespace || null;
|
|
38
38
|
const teamNSOverride = args._teamNS || null;
|
|
39
39
|
|
|
40
40
|
// Silent mode: wrap fmt to suppress all output and exit cleanly on errors
|
|
@@ -101,7 +101,13 @@ export async function pullCommand(args) {
|
|
|
101
101
|
const s = log.spinner();
|
|
102
102
|
s.start('Fetching from registry...');
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
// When pulling from template with rename, also fetch the actual namespace —
|
|
105
|
+
// if it exists in the registry, use it directly instead of the template.
|
|
106
|
+
const pathsToFetch = [pattern];
|
|
107
|
+
if (renameNamespace && pattern === '[template]') {
|
|
108
|
+
pathsToFetch.push(renameNamespace);
|
|
109
|
+
}
|
|
110
|
+
const sparsePaths = includeToSparsePaths(pathsToFetch);
|
|
105
111
|
let tempDir;
|
|
106
112
|
try {
|
|
107
113
|
tempDir = sparseCheckout(cfg.repo, sparsePaths);
|
|
@@ -111,9 +117,22 @@ export async function pullCommand(args) {
|
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
try {
|
|
114
|
-
const registryDirs = [];
|
|
115
120
|
const regBase = join(tempDir, REGISTRY_DIR);
|
|
116
121
|
|
|
122
|
+
// Check if actual namespace exists in the registry
|
|
123
|
+
if (renameNamespace && pattern === '[template]') {
|
|
124
|
+
const actualNsTopDir = renameNamespace.split('/')[0];
|
|
125
|
+
const actualNsPath = join(regBase, actualNsTopDir);
|
|
126
|
+
if (existsSync(actualNsPath)) {
|
|
127
|
+
const fullNsPath = join(regBase, ...renameNamespace.split('/'));
|
|
128
|
+
if (existsSync(fullNsPath) && listDirs(fullNsPath).length > 0) {
|
|
129
|
+
pattern = renameNamespace;
|
|
130
|
+
renameNamespace = null; // No rename needed — using actual content
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const registryDirs = [];
|
|
117
136
|
if (existsSync(regBase)) {
|
|
118
137
|
for (const name of listDirs(regBase)) {
|
|
119
138
|
registryDirs.push({ name, path: join(regBase, name) });
|
|
@@ -226,7 +245,7 @@ export async function pullCommand(args) {
|
|
|
226
245
|
export async function pullAsync(args) {
|
|
227
246
|
const input = args._positional?.[0] || '';
|
|
228
247
|
const workspaceDir = args._workspaceDir;
|
|
229
|
-
|
|
248
|
+
let renameNamespace = args._renameNamespace || null;
|
|
230
249
|
const teamNSOverride = args._teamNS || null;
|
|
231
250
|
|
|
232
251
|
const resolved = resolveInput(input, workspaceDir);
|
|
@@ -238,13 +257,35 @@ export async function pullAsync(args) {
|
|
|
238
257
|
const cfg = config.load(workspaceDir);
|
|
239
258
|
if (!cfg) throw new Error('No .sync-config.json found');
|
|
240
259
|
|
|
241
|
-
|
|
260
|
+
// When pulling from template with rename, also fetch the actual namespace —
|
|
261
|
+
// if it exists in the registry, use it directly instead of the template.
|
|
262
|
+
const pathsToFetch = [pattern];
|
|
263
|
+
if (renameNamespace && pattern === '[template]') {
|
|
264
|
+
pathsToFetch.push(renameNamespace);
|
|
265
|
+
}
|
|
266
|
+
const sparsePaths = includeToSparsePaths(pathsToFetch);
|
|
242
267
|
const tempDir = await sparseCheckoutAsync(cfg.repo, sparsePaths);
|
|
243
268
|
|
|
244
269
|
try {
|
|
245
|
-
const registryDirs = [];
|
|
246
270
|
const regBase = join(tempDir, REGISTRY_DIR);
|
|
247
271
|
|
|
272
|
+
// Check if actual namespace exists in the registry
|
|
273
|
+
let useActualNamespace = false;
|
|
274
|
+
if (renameNamespace && pattern === '[template]') {
|
|
275
|
+
const actualNsTopDir = renameNamespace.split('/')[0];
|
|
276
|
+
const actualNsPath = join(regBase, actualNsTopDir);
|
|
277
|
+
if (existsSync(actualNsPath)) {
|
|
278
|
+
// Verify the full namespace path has content (not just the top-level team dir)
|
|
279
|
+
const fullNsPath = join(regBase, ...renameNamespace.split('/'));
|
|
280
|
+
if (existsSync(fullNsPath) && listDirs(fullNsPath).length > 0) {
|
|
281
|
+
useActualNamespace = true;
|
|
282
|
+
pattern = renameNamespace;
|
|
283
|
+
renameNamespace = null; // No rename needed — using actual content
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const registryDirs = [];
|
|
248
289
|
if (existsSync(regBase)) {
|
|
249
290
|
for (const name of listDirs(regBase)) {
|
|
250
291
|
registryDirs.push({ name, path: join(regBase, name) });
|