@orxataguy/tyr 1.0.42 → 1.0.43
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/package.json +1 -1
- package/src/core/sys/modules.ts +15 -3
package/package.json
CHANGED
package/src/core/sys/modules.ts
CHANGED
|
@@ -41,8 +41,19 @@ function isValidHttpsUrl(value: string): boolean {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Allows namespaced command names like 'db:migrate', but not a leading/
|
|
45
|
+
// trailing/doubled ':' (e.g. ':foo', 'foo:', 'a::b'), since those would
|
|
46
|
+
// produce an empty segment.
|
|
44
47
|
function isValidCommandName(name: string): boolean {
|
|
45
|
-
return /^[a-zA-Z0-9_-]
|
|
48
|
+
return /^[a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*$/.test(name);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ':' is a valid character in a command name (namespacing, e.g. 'db:migrate')
|
|
52
|
+
// but isn't a safe filename component on every platform (Windows reserves it).
|
|
53
|
+
// Only used when deriving the on-disk file name — the real name with its
|
|
54
|
+
// colons is still what's stored in map.yml, the lockfile, and the manifest.
|
|
55
|
+
function toSafeFilename(commandName: string): string {
|
|
56
|
+
return commandName.replace(/:/g, '-');
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
function slugFromUrl(url: string): string {
|
|
@@ -183,14 +194,15 @@ export async function syncModules(context: TyrContext, options: { force?: boolea
|
|
|
183
194
|
const content = await web.get(fileUrl);
|
|
184
195
|
const fileContent = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
|
|
185
196
|
|
|
186
|
-
const
|
|
197
|
+
const fileName = toSafeFilename(commandName);
|
|
198
|
+
const destPath = path.join(userRoot, 'commands', `${fileName}.tyr.ts`);
|
|
187
199
|
await fs.write(destPath, fileContent);
|
|
188
200
|
|
|
189
201
|
if (managed && managed.module !== moduleName) {
|
|
190
202
|
logger.warn(`'${commandName}' was previously managed by module '${managed.module}'; now owned by '${moduleName}'.`);
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
mapConfig.commands[commandName] = `./commands/${
|
|
205
|
+
mapConfig.commands[commandName] = `./commands/${fileName}.tyr.ts`;
|
|
194
206
|
lock.commands[commandName] = { module: moduleName, manifest: manifestUrl, source: fileUrl };
|
|
195
207
|
mapChanged = true;
|
|
196
208
|
lockChanged = true;
|