planmode 0.1.1 → 0.1.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/dist/index.js +18 -4
- package/package.json +1 -1
- package/src/commands/install.ts +16 -1
- package/src/lib/installer.ts +3 -2
- package/src/types/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -644,10 +644,11 @@ async function installPackage(packageName, options = {}) {
|
|
|
644
644
|
const { version, metadata } = await resolveVersion(packageName, options.version);
|
|
645
645
|
const versionMeta = await fetchVersionMetadata(packageName, version);
|
|
646
646
|
logger.info(`Fetching ${packageName}@${version}...`);
|
|
647
|
+
const basePath = versionMeta.source.path ? `${versionMeta.source.path}/` : "";
|
|
647
648
|
const manifestRaw = await fetchFileAtTag(
|
|
648
649
|
versionMeta.source.repository,
|
|
649
650
|
versionMeta.source.tag,
|
|
650
|
-
|
|
651
|
+
`${basePath}planmode.yaml`
|
|
651
652
|
);
|
|
652
653
|
const manifest = parseManifest(manifestRaw);
|
|
653
654
|
let content;
|
|
@@ -657,7 +658,7 @@ async function installPackage(packageName, options = {}) {
|
|
|
657
658
|
content = await fetchFileAtTag(
|
|
658
659
|
versionMeta.source.repository,
|
|
659
660
|
versionMeta.source.tag,
|
|
660
|
-
manifest.content_file
|
|
661
|
+
`${basePath}${manifest.content_file}`
|
|
661
662
|
);
|
|
662
663
|
} else {
|
|
663
664
|
throw new Error("Package has no content or content_file");
|
|
@@ -752,14 +753,27 @@ async function updatePackage(packageName, projectDir = process.cwd()) {
|
|
|
752
753
|
}
|
|
753
754
|
|
|
754
755
|
// src/commands/install.ts
|
|
755
|
-
|
|
756
|
+
function parseVariables(pairs) {
|
|
757
|
+
const vars = {};
|
|
758
|
+
for (const pair of pairs) {
|
|
759
|
+
const eq = pair.indexOf("=");
|
|
760
|
+
if (eq === -1) {
|
|
761
|
+
throw new Error(`Invalid variable format: "${pair}". Use --set key=value`);
|
|
762
|
+
}
|
|
763
|
+
vars[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
764
|
+
}
|
|
765
|
+
return vars;
|
|
766
|
+
}
|
|
767
|
+
var installCommand = new Command("install").description("Install a package into the current project").argument("<package>", "Package name (e.g., nextjs-tailwind-starter)").option("-v, --version <version>", "Install specific version").option("--rule", "Force install as a rule to .claude/rules/").option("--no-input", "Fail if any required variable is missing").option("--set <key=value...>", "Set template variables (e.g., --set project_name=myapp)").action(
|
|
756
768
|
async (packageName, options) => {
|
|
757
769
|
try {
|
|
758
770
|
logger.blank();
|
|
771
|
+
const variables = options.set ? parseVariables(options.set) : void 0;
|
|
759
772
|
await installPackage(packageName, {
|
|
760
773
|
version: options.version,
|
|
761
774
|
forceRule: options.rule,
|
|
762
|
-
noInput: options.input === false
|
|
775
|
+
noInput: options.input === false,
|
|
776
|
+
variables
|
|
763
777
|
});
|
|
764
778
|
logger.blank();
|
|
765
779
|
} catch (err) {
|
package/package.json
CHANGED
package/src/commands/install.ts
CHANGED
|
@@ -2,23 +2,38 @@ import { Command } from "commander";
|
|
|
2
2
|
import { installPackage } from "../lib/installer.js";
|
|
3
3
|
import { logger } from "../lib/logger.js";
|
|
4
4
|
|
|
5
|
+
function parseVariables(pairs: string[]): Record<string, string> {
|
|
6
|
+
const vars: Record<string, string> = {};
|
|
7
|
+
for (const pair of pairs) {
|
|
8
|
+
const eq = pair.indexOf("=");
|
|
9
|
+
if (eq === -1) {
|
|
10
|
+
throw new Error(`Invalid variable format: "${pair}". Use --set key=value`);
|
|
11
|
+
}
|
|
12
|
+
vars[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
13
|
+
}
|
|
14
|
+
return vars;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
export const installCommand = new Command("install")
|
|
6
18
|
.description("Install a package into the current project")
|
|
7
19
|
.argument("<package>", "Package name (e.g., nextjs-tailwind-starter)")
|
|
8
20
|
.option("-v, --version <version>", "Install specific version")
|
|
9
21
|
.option("--rule", "Force install as a rule to .claude/rules/")
|
|
10
22
|
.option("--no-input", "Fail if any required variable is missing")
|
|
23
|
+
.option("--set <key=value...>", "Set template variables (e.g., --set project_name=myapp)")
|
|
11
24
|
.action(
|
|
12
25
|
async (
|
|
13
26
|
packageName: string,
|
|
14
|
-
options: { version?: string; rule?: boolean; input?: boolean },
|
|
27
|
+
options: { version?: string; rule?: boolean; input?: boolean; set?: string[] },
|
|
15
28
|
) => {
|
|
16
29
|
try {
|
|
17
30
|
logger.blank();
|
|
31
|
+
const variables = options.set ? parseVariables(options.set) : undefined;
|
|
18
32
|
await installPackage(packageName, {
|
|
19
33
|
version: options.version,
|
|
20
34
|
forceRule: options.rule,
|
|
21
35
|
noInput: options.input === false,
|
|
36
|
+
variables,
|
|
22
37
|
});
|
|
23
38
|
logger.blank();
|
|
24
39
|
} catch (err) {
|
package/src/lib/installer.ts
CHANGED
|
@@ -60,10 +60,11 @@ export async function installPackage(
|
|
|
60
60
|
|
|
61
61
|
// Fetch manifest
|
|
62
62
|
logger.info(`Fetching ${packageName}@${version}...`);
|
|
63
|
+
const basePath = versionMeta.source.path ? `${versionMeta.source.path}/` : "";
|
|
63
64
|
const manifestRaw = await fetchFileAtTag(
|
|
64
65
|
versionMeta.source.repository,
|
|
65
66
|
versionMeta.source.tag,
|
|
66
|
-
|
|
67
|
+
`${basePath}planmode.yaml`,
|
|
67
68
|
);
|
|
68
69
|
const manifest = parseManifest(manifestRaw);
|
|
69
70
|
|
|
@@ -75,7 +76,7 @@ export async function installPackage(
|
|
|
75
76
|
content = await fetchFileAtTag(
|
|
76
77
|
versionMeta.source.repository,
|
|
77
78
|
versionMeta.source.tag,
|
|
78
|
-
manifest.content_file
|
|
79
|
+
`${basePath}${manifest.content_file}`,
|
|
79
80
|
);
|
|
80
81
|
} else {
|
|
81
82
|
throw new Error("Package has no content or content_file");
|