dotmd-cli 0.49.1 → 0.49.2
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/new.mjs +14 -5
- package/src/ship.mjs +1 -0
package/package.json
CHANGED
package/src/new.mjs
CHANGED
|
@@ -271,6 +271,16 @@ function readBodyInput(source) {
|
|
|
271
271
|
export async function runNew(argv, config, opts = {}) {
|
|
272
272
|
const { dryRun } = opts;
|
|
273
273
|
|
|
274
|
+
const knownTypes = new Set(Object.keys(BUILTIN_TEMPLATES));
|
|
275
|
+
// Also include any custom templates from config
|
|
276
|
+
for (const k of Object.keys(config.raw?.templates ?? {})) knownTypes.add(k);
|
|
277
|
+
|
|
278
|
+
const hasNameForBody = args => {
|
|
279
|
+
if (args.length >= 2 && knownTypes.has(args[0])) return true;
|
|
280
|
+
if (args.length >= 1 && !knownTypes.has(args[0])) return true;
|
|
281
|
+
return false;
|
|
282
|
+
};
|
|
283
|
+
|
|
274
284
|
// Parse args. Pull out flags first.
|
|
275
285
|
const positional = [];
|
|
276
286
|
let status = null;
|
|
@@ -296,17 +306,16 @@ export async function runNew(argv, config, opts = {}) {
|
|
|
296
306
|
return;
|
|
297
307
|
}
|
|
298
308
|
// Treat `-` alone (stdin marker) as a positional, not a flag.
|
|
299
|
-
|
|
309
|
+
// Once the type/name have been collected, a positional body may itself
|
|
310
|
+
// start with `---` frontmatter. Preserve it instead of dropping it as an
|
|
311
|
+
// unknown flag; the leading frontmatter merge below will handle it.
|
|
312
|
+
if (!argv[i].startsWith('-') || argv[i] === '-' || hasNameForBody(positional)) positional.push(argv[i]);
|
|
300
313
|
}
|
|
301
314
|
|
|
302
315
|
// Resolve type vs name:
|
|
303
316
|
// `dotmd new plan auth-revamp` → type=plan, name=auth-revamp
|
|
304
317
|
// `dotmd new auth-revamp` → type=doc (default), name=auth-revamp
|
|
305
318
|
// `dotmd new prompt foo "body"` → type=prompt, name=foo, bodyArg="body"
|
|
306
|
-
const knownTypes = new Set(Object.keys(BUILTIN_TEMPLATES));
|
|
307
|
-
// Also include any custom templates from config
|
|
308
|
-
for (const k of Object.keys(config.raw?.templates ?? {})) knownTypes.add(k);
|
|
309
|
-
|
|
310
319
|
let typeName, name, bodyArg = null;
|
|
311
320
|
if (positional.length >= 1 && knownTypes.has(positional[0])) {
|
|
312
321
|
typeName = positional[0];
|