@drupal-canvas/create 1.4.0 → 1.5.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 +15 -15
- package/dist/index.js +202 -114
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,40 +22,40 @@ pnpm dlx @drupal-canvas/create@latest
|
|
|
22
22
|
bunx @drupal-canvas/create@latest
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
You can also provide the
|
|
25
|
+
You can also provide the project name as an argument:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npx @drupal-canvas/create@latest my-
|
|
28
|
+
npx @drupal-canvas/create@latest my-project
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Options
|
|
32
32
|
|
|
33
|
-
| Option | Description
|
|
34
|
-
| --------------- |
|
|
35
|
-
| `--template -t` | Template to use when scaffolding the
|
|
36
|
-
| `--ref <ref>` | Custom Git ref to use when cloning the template repository. For example, a branch name or a tag.
|
|
37
|
-
| `--agents -a` | Comma-separated list of additional agents to support, or `none` to skip compatibility symlink creation.
|
|
33
|
+
| Option | Description |
|
|
34
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `--template -t` | Template to use when scaffolding the project. One of the predefined templates (currently available: `acquia-nebula`, `balintbrews-canvas-starter`) or URL to custom template's Git repository. |
|
|
36
|
+
| `--ref <ref>` | Custom Git ref to use when cloning the template repository. For example, a branch name or a tag. |
|
|
37
|
+
| `--agents -a` | Comma-separated list of additional agents to support, or `none` to skip compatibility symlink creation. |
|
|
38
38
|
|
|
39
39
|
### Example
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npx @drupal-canvas/create@latest my-
|
|
42
|
+
npx @drupal-canvas/create@latest my-project --template acquia-nebula
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Explicitly skip additional agent compatibility symlinks:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
npx @drupal-canvas/create@latest my-
|
|
48
|
+
npx @drupal-canvas/create@latest my-project --template acquia-nebula --agents none
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Provide additional agent compatibility symlinks without prompting:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
npx @drupal-canvas/create@latest my-
|
|
54
|
+
npx @drupal-canvas/create@latest my-project --template acquia-nebula --agents claude-code,roo
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
If `--agents` is omitted, the CLI keeps the current interactive prompt on TTY
|
|
58
|
-
runs. On non-interactive runs, it skips compatibility setup
|
|
58
|
+
runs. On non-interactive runs, it skips compatibility setup and prints a note.
|
|
59
59
|
|
|
60
60
|
### `agents` command
|
|
61
61
|
|
|
@@ -82,7 +82,7 @@ npx @drupal-canvas/create@latest agents none
|
|
|
82
82
|
|
|
83
83
|
Drupal Canvas Create is designed to be easily extendable with new templates.
|
|
84
84
|
|
|
85
|
-
**Templates** are predefined
|
|
85
|
+
**Templates** are predefined Canvas project starter codebases. Each template
|
|
86
86
|
references a Git repository that will be cloned to provide the initial codebase.
|
|
87
87
|
To add a template, edit `templates.json` in the package root.
|
|
88
88
|
|
|
@@ -103,9 +103,9 @@ npm start
|
|
|
103
103
|
Alternatively, use `npm run dev` to compile and watch for changes during
|
|
104
104
|
development.
|
|
105
105
|
|
|
106
|
-
⚠️ You must use `my-canvas-
|
|
107
|
-
when running the script from a local directory. (Reasons are explained in
|
|
108
|
-
`.gitignore` file where we had to ignore this directory.)
|
|
106
|
+
⚠️ You must use `my-canvas-project` (provided as default value) as your project
|
|
107
|
+
name when running the script from a local directory. (Reasons are explained in
|
|
108
|
+
the `.gitignore` file where we had to ignore this directory.)
|
|
109
109
|
|
|
110
110
|
### Scripts
|
|
111
111
|
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,10 @@ var templates_default = [
|
|
|
35
35
|
|
|
36
36
|
// src/lib/agents.ts
|
|
37
37
|
var agents = {
|
|
38
|
+
"aider-desk": {
|
|
39
|
+
displayName: "AiderDesk",
|
|
40
|
+
skillsDir: ".aider-desk/skills"
|
|
41
|
+
},
|
|
38
42
|
amp: {
|
|
39
43
|
displayName: "Amp",
|
|
40
44
|
skillsDir: ".agents/skills"
|
|
@@ -47,6 +51,10 @@ var agents = {
|
|
|
47
51
|
displayName: "Augment",
|
|
48
52
|
skillsDir: ".augment/skills"
|
|
49
53
|
},
|
|
54
|
+
bob: {
|
|
55
|
+
displayName: "IBM Bob",
|
|
56
|
+
skillsDir: ".bob/skills"
|
|
57
|
+
},
|
|
50
58
|
"claude-code": {
|
|
51
59
|
displayName: "Claude Code",
|
|
52
60
|
skillsDir: ".claude/skills"
|
|
@@ -59,10 +67,22 @@ var agents = {
|
|
|
59
67
|
displayName: "Cline",
|
|
60
68
|
skillsDir: ".agents/skills"
|
|
61
69
|
},
|
|
70
|
+
"codearts-agent": {
|
|
71
|
+
displayName: "CodeArts Agent",
|
|
72
|
+
skillsDir: ".codeartsdoer/skills"
|
|
73
|
+
},
|
|
62
74
|
codebuddy: {
|
|
63
75
|
displayName: "CodeBuddy",
|
|
64
76
|
skillsDir: ".codebuddy/skills"
|
|
65
77
|
},
|
|
78
|
+
codemaker: {
|
|
79
|
+
displayName: "Codemaker",
|
|
80
|
+
skillsDir: ".codemaker/skills"
|
|
81
|
+
},
|
|
82
|
+
codestudio: {
|
|
83
|
+
displayName: "Code Studio",
|
|
84
|
+
skillsDir: ".codestudio/skills"
|
|
85
|
+
},
|
|
66
86
|
codex: {
|
|
67
87
|
displayName: "Codex",
|
|
68
88
|
skillsDir: ".agents/skills"
|
|
@@ -91,10 +111,26 @@ var agents = {
|
|
|
91
111
|
displayName: "Deep Agents",
|
|
92
112
|
skillsDir: ".agents/skills"
|
|
93
113
|
},
|
|
114
|
+
devin: {
|
|
115
|
+
displayName: "Devin for Terminal",
|
|
116
|
+
skillsDir: ".devin/skills"
|
|
117
|
+
},
|
|
118
|
+
dexto: {
|
|
119
|
+
displayName: "Dexto",
|
|
120
|
+
skillsDir: ".agents/skills"
|
|
121
|
+
},
|
|
94
122
|
droid: {
|
|
95
123
|
displayName: "Droid",
|
|
96
124
|
skillsDir: ".factory/skills"
|
|
97
125
|
},
|
|
126
|
+
firebender: {
|
|
127
|
+
displayName: "Firebender",
|
|
128
|
+
skillsDir: ".agents/skills"
|
|
129
|
+
},
|
|
130
|
+
forgecode: {
|
|
131
|
+
displayName: "ForgeCode",
|
|
132
|
+
skillsDir: ".forge/skills"
|
|
133
|
+
},
|
|
98
134
|
"gemini-cli": {
|
|
99
135
|
displayName: "Gemini CLI",
|
|
100
136
|
skillsDir: ".agents/skills"
|
|
@@ -107,6 +143,10 @@ var agents = {
|
|
|
107
143
|
displayName: "Goose",
|
|
108
144
|
skillsDir: ".goose/skills"
|
|
109
145
|
},
|
|
146
|
+
"hermes-agent": {
|
|
147
|
+
displayName: "Hermes Agent",
|
|
148
|
+
skillsDir: ".hermes/skills"
|
|
149
|
+
},
|
|
110
150
|
junie: {
|
|
111
151
|
displayName: "Junie",
|
|
112
152
|
skillsDir: ".junie/skills"
|
|
@@ -168,10 +208,18 @@ var agents = {
|
|
|
168
208
|
skillsDir: ".agents/skills",
|
|
169
209
|
showInUniversalList: false
|
|
170
210
|
},
|
|
211
|
+
rovodev: {
|
|
212
|
+
displayName: "Rovo Dev",
|
|
213
|
+
skillsDir: ".rovodev/skills"
|
|
214
|
+
},
|
|
171
215
|
roo: {
|
|
172
216
|
displayName: "Roo Code",
|
|
173
217
|
skillsDir: ".roo/skills"
|
|
174
218
|
},
|
|
219
|
+
"tabnine-cli": {
|
|
220
|
+
displayName: "Tabnine CLI",
|
|
221
|
+
skillsDir: ".tabnine/agent/skills"
|
|
222
|
+
},
|
|
175
223
|
trae: {
|
|
176
224
|
displayName: "Trae",
|
|
177
225
|
skillsDir: ".trae/skills"
|
|
@@ -180,6 +228,11 @@ var agents = {
|
|
|
180
228
|
displayName: "Trae CN",
|
|
181
229
|
skillsDir: ".trae/skills"
|
|
182
230
|
},
|
|
231
|
+
universal: {
|
|
232
|
+
displayName: "Universal",
|
|
233
|
+
skillsDir: ".agents/skills",
|
|
234
|
+
showInUniversalList: false
|
|
235
|
+
},
|
|
183
236
|
warp: {
|
|
184
237
|
displayName: "Warp",
|
|
185
238
|
skillsDir: ".agents/skills"
|
|
@@ -188,6 +241,10 @@ var agents = {
|
|
|
188
241
|
displayName: "Windsurf",
|
|
189
242
|
skillsDir: ".windsurf/skills"
|
|
190
243
|
},
|
|
244
|
+
zed: {
|
|
245
|
+
displayName: "Zed",
|
|
246
|
+
skillsDir: ".agents/skills"
|
|
247
|
+
},
|
|
191
248
|
zencoder: {
|
|
192
249
|
displayName: "Zencoder",
|
|
193
250
|
skillsDir: ".zencoder/skills"
|
|
@@ -487,6 +544,9 @@ async function setupAgentSkills(projectDir, options = {}) {
|
|
|
487
544
|
const hasExplicitSelection = options.selectedAgents !== void 0;
|
|
488
545
|
try {
|
|
489
546
|
if (!hasExplicitSelection && !interactive) {
|
|
547
|
+
info(
|
|
548
|
+
"Agent compatibility skipped because the command is non-interactive. Use --agents to enable it."
|
|
549
|
+
);
|
|
490
550
|
return;
|
|
491
551
|
}
|
|
492
552
|
const canonicalSkillsDir = join(projectDir, DEFAULT_SKILLS_DIR);
|
|
@@ -528,8 +588,12 @@ async function setupAgentSkills(projectDir, options = {}) {
|
|
|
528
588
|
skillNames,
|
|
529
589
|
selectedAgents: nonUniversalAgents
|
|
530
590
|
});
|
|
531
|
-
|
|
532
|
-
|
|
591
|
+
info(
|
|
592
|
+
`Agent compatibility:
|
|
593
|
+
${nonUniversalAgents.map(
|
|
594
|
+
(agent) => `- ${agents[agent].displayName}: ${agents[agent].skillsDir}`
|
|
595
|
+
).join("\n")}`
|
|
596
|
+
);
|
|
533
597
|
if (results.created.length > 0) {
|
|
534
598
|
info(
|
|
535
599
|
`Created compatibility ${pluralize("symlink", results.created.length)} (${skillNames.length} ${pluralize("skill", skillNames.length)} \xD7 ${nonUniversalAgents.length} ${pluralize("agent", nonUniversalAgents.length)}).`
|
|
@@ -556,7 +620,7 @@ async function defaultPromptForAgents() {
|
|
|
556
620
|
const additionalAgents = getNonUniversalAgents();
|
|
557
621
|
p4.log.message("");
|
|
558
622
|
const selected = await searchMultiselect({
|
|
559
|
-
message: "Which
|
|
623
|
+
message: "Which AI coding agents should this codebase support?",
|
|
560
624
|
items: additionalAgents.map((agent) => ({
|
|
561
625
|
value: agent,
|
|
562
626
|
label: agents[agent].displayName,
|
|
@@ -635,7 +699,7 @@ function agentsCommand(program2) {
|
|
|
635
699
|
selectedAgents,
|
|
636
700
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
637
701
|
});
|
|
638
|
-
p4.outro("
|
|
702
|
+
p4.outro("Agent compatibility setup complete.");
|
|
639
703
|
} catch (error) {
|
|
640
704
|
if (error instanceof Error) {
|
|
641
705
|
p4.log.error(`Error: ${error.message}`);
|
|
@@ -665,7 +729,7 @@ function detectPackageManager() {
|
|
|
665
729
|
// package.json
|
|
666
730
|
var package_default = {
|
|
667
731
|
name: "@drupal-canvas/create",
|
|
668
|
-
version: "1.
|
|
732
|
+
version: "1.5.0",
|
|
669
733
|
description: "CLI to scaffold a codebase for working with Drupal Canvas Code Components"};
|
|
670
734
|
|
|
671
735
|
// src/lib/meta-info.ts
|
|
@@ -673,15 +737,23 @@ var getName = () => package_default.name;
|
|
|
673
737
|
var getDescription = () => package_default.description;
|
|
674
738
|
var getVersion = () => package_default.version;
|
|
675
739
|
var GIT_TERMINAL_PROMPT = 0;
|
|
676
|
-
var
|
|
740
|
+
var unsafe = {
|
|
741
|
+
allowUnsafeEditor: true,
|
|
742
|
+
allowUnsafePager: true
|
|
743
|
+
};
|
|
744
|
+
var use_git_default = (baseDir) => {
|
|
745
|
+
const options = { unsafe };
|
|
746
|
+
const git = baseDir === void 0 ? simpleGit(options) : simpleGit(baseDir, options);
|
|
747
|
+
return git.env({ ...process.env, GIT_TERMINAL_PROMPT });
|
|
748
|
+
};
|
|
677
749
|
|
|
678
750
|
// src/create.ts
|
|
679
|
-
async function
|
|
680
|
-
const { template,
|
|
681
|
-
const projectDir = `${process.cwd()}/${
|
|
751
|
+
async function createProject(ctx) {
|
|
752
|
+
const { template, projectName, selectedAgents } = ctx;
|
|
753
|
+
const projectDir = `${process.cwd()}/${projectName}`;
|
|
682
754
|
try {
|
|
683
755
|
const s1 = p4.spinner();
|
|
684
|
-
s1.start("Fetching
|
|
756
|
+
s1.start("Fetching template");
|
|
685
757
|
const hasCommitSHARef = /^[a-f0-9]{40}$/i.test(template.repository.ref);
|
|
686
758
|
const git = use_git_default();
|
|
687
759
|
const options = {
|
|
@@ -690,32 +762,32 @@ async function createApp(ctx) {
|
|
|
690
762
|
if (template.repository.ref !== "HEAD" && !hasCommitSHARef) {
|
|
691
763
|
options["--branch"] = template.repository.ref;
|
|
692
764
|
}
|
|
693
|
-
await git.clone(template.repository.url,
|
|
694
|
-
const
|
|
765
|
+
await git.clone(template.repository.url, projectName, options);
|
|
766
|
+
const gitProjectDir = use_git_default(projectDir);
|
|
695
767
|
if (hasCommitSHARef) {
|
|
696
|
-
await
|
|
697
|
-
await
|
|
768
|
+
await gitProjectDir.fetch("origin", template.repository.ref);
|
|
769
|
+
await gitProjectDir.checkout(template.repository.ref);
|
|
698
770
|
}
|
|
699
771
|
await rimraf(`${projectDir}/.git`);
|
|
700
772
|
const packageJsonPath = join(projectDir, "package.json");
|
|
701
773
|
const packageJsonContent = await readFile(packageJsonPath, "utf-8");
|
|
702
774
|
const packageJson = JSON.parse(packageJsonContent);
|
|
703
|
-
packageJson.name =
|
|
775
|
+
packageJson.name = projectName;
|
|
704
776
|
await writeFile(
|
|
705
777
|
packageJsonPath,
|
|
706
778
|
JSON.stringify(packageJson, null, 2) + "\n"
|
|
707
779
|
);
|
|
708
|
-
s1.stop(chalk2.green("Fetched
|
|
780
|
+
s1.stop(chalk2.green("Fetched template"));
|
|
709
781
|
await setupAgentSkills(projectDir, {
|
|
710
782
|
selectedAgents,
|
|
711
783
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
712
784
|
});
|
|
713
785
|
const s2 = p4.spinner();
|
|
714
786
|
const packageManager = detectPackageManager();
|
|
715
|
-
s2.start(`Installing dependencies
|
|
787
|
+
s2.start(`Installing dependencies with ${packageManager}`);
|
|
716
788
|
await new Promise((resolve, reject) => {
|
|
717
789
|
const child = spawn(packageManager, ["install"], {
|
|
718
|
-
cwd: `./${
|
|
790
|
+
cwd: `./${projectName}`,
|
|
719
791
|
stdio: ["ignore", "ignore", "pipe"],
|
|
720
792
|
env: {
|
|
721
793
|
...process.env,
|
|
@@ -734,7 +806,10 @@ async function createApp(ctx) {
|
|
|
734
806
|
if (code !== 0) {
|
|
735
807
|
reject(
|
|
736
808
|
new Error(
|
|
737
|
-
`Package installation failed with code ${code}
|
|
809
|
+
`Package installation failed with code ${code}.
|
|
810
|
+
Failed command: ${packageManager} install
|
|
811
|
+
Working directory: ./${projectName}${stderrOutput ? `
|
|
812
|
+
|
|
738
813
|
${stderrOutput}` : ""}`
|
|
739
814
|
)
|
|
740
815
|
);
|
|
@@ -743,21 +818,29 @@ ${stderrOutput}` : ""}`
|
|
|
743
818
|
}
|
|
744
819
|
});
|
|
745
820
|
});
|
|
746
|
-
s2.stop(chalk2.green(
|
|
821
|
+
s2.stop(chalk2.green(`Installed dependencies with ${packageManager}`));
|
|
747
822
|
const s3 = p4.spinner();
|
|
748
|
-
s3.start("
|
|
749
|
-
await git.init(["--initial-branch=main",
|
|
750
|
-
await
|
|
751
|
-
await
|
|
752
|
-
`Init
|
|
823
|
+
s3.start("Initializing Git repository");
|
|
824
|
+
await git.init(["--initial-branch=main", projectName]);
|
|
825
|
+
await gitProjectDir.add(["--all"]);
|
|
826
|
+
await gitProjectDir.commit(
|
|
827
|
+
`Init project using ${getName()}@${getVersion()}
|
|
753
828
|
|
|
754
829
|
Template repository: ${template.repository.url}
|
|
755
830
|
Ref: ${template.repository.ref}`
|
|
756
831
|
);
|
|
757
|
-
s3.stop(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
p4.
|
|
832
|
+
s3.stop(
|
|
833
|
+
chalk2.green("Initialized Git repository on main with initial commit")
|
|
834
|
+
);
|
|
835
|
+
p4.note(
|
|
836
|
+
`Created project in ./${projectName}
|
|
837
|
+
|
|
838
|
+
Next steps:
|
|
839
|
+
cd ${projectName}
|
|
840
|
+
${packageManager} run dev`,
|
|
841
|
+
"Get started"
|
|
842
|
+
);
|
|
843
|
+
p4.outro("Canvas project created successfully.");
|
|
761
844
|
} catch (error) {
|
|
762
845
|
if (error instanceof Error) {
|
|
763
846
|
p4.log.error(`Error: ${error.message}`);
|
|
@@ -785,7 +868,7 @@ function validateName(name) {
|
|
|
785
868
|
process.on("SIGINT", () => process.exit(0));
|
|
786
869
|
process.on("SIGTERM", () => process.exit(0));
|
|
787
870
|
var program = new Command();
|
|
788
|
-
program.name(getName()).description(getDescription()).version(getVersion()).argument("[
|
|
871
|
+
program.name(getName()).description(getDescription()).version(getVersion()).argument("[project-name]", "name of the project to create").option(
|
|
789
872
|
"-t, --template <template>",
|
|
790
873
|
"use template when scaffolding (predefined name or custom Git repository URL)"
|
|
791
874
|
).option(
|
|
@@ -794,101 +877,106 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
|
|
|
794
877
|
).option(
|
|
795
878
|
"-a, --agents <agents>",
|
|
796
879
|
'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
|
|
797
|
-
).action(
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
880
|
+
).action(
|
|
881
|
+
async (projectNameArg, options) => {
|
|
882
|
+
p4.intro(chalk2.bold("Drupal Canvas Create"));
|
|
883
|
+
try {
|
|
884
|
+
const selectedAgents = parseAgentSelection(options.agents);
|
|
885
|
+
if (options.template) {
|
|
886
|
+
const template2 = templates_default.find(
|
|
887
|
+
(t) => t.id === options.template
|
|
888
|
+
);
|
|
889
|
+
const isCustomRepositoryUrl = [
|
|
890
|
+
// Remote repositories.
|
|
891
|
+
"https://",
|
|
892
|
+
"http://",
|
|
893
|
+
"git@",
|
|
894
|
+
// Local repositories.
|
|
895
|
+
"../",
|
|
896
|
+
"./",
|
|
897
|
+
"/"
|
|
898
|
+
].some((prefix) => options.template?.startsWith(prefix));
|
|
899
|
+
if (!template2 && isCustomRepositoryUrl) {
|
|
900
|
+
templates_default.push({
|
|
901
|
+
id: options.template,
|
|
902
|
+
label: options.template,
|
|
903
|
+
repository: {
|
|
904
|
+
url: options.template,
|
|
905
|
+
ref: "HEAD"
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
} else if (!template2) {
|
|
909
|
+
p4.log.error(
|
|
910
|
+
`Template "${options.template}" not found.
|
|
911
|
+
|
|
912
|
+
Available templates:
|
|
913
|
+
${templates_default.map((availableTemplate) => `- ${availableTemplate.id}`).join("\n")}`
|
|
914
|
+
);
|
|
915
|
+
process.exit(1);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
let projectName = projectNameArg;
|
|
919
|
+
if (!projectName) {
|
|
920
|
+
const name = await p4.text({
|
|
921
|
+
message: "Enter the project name",
|
|
922
|
+
initialValue: "my-canvas-project",
|
|
923
|
+
validate: (value) => {
|
|
924
|
+
if (!value) return "Project name is required";
|
|
925
|
+
const { valid, problems } = validateName(value);
|
|
926
|
+
if (!valid) {
|
|
927
|
+
return problems.join(", ");
|
|
928
|
+
}
|
|
929
|
+
return;
|
|
822
930
|
}
|
|
823
931
|
});
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
932
|
+
if (p4.isCancel(name)) {
|
|
933
|
+
p4.cancel("Operation cancelled");
|
|
934
|
+
process.exit(0);
|
|
935
|
+
}
|
|
936
|
+
projectName = name;
|
|
937
|
+
} else {
|
|
938
|
+
const { valid, problems } = validateName(projectName);
|
|
939
|
+
if (!valid) {
|
|
940
|
+
p4.log.error(`Invalid project name: ${problems.join(", ")}`);
|
|
941
|
+
process.exit(1);
|
|
942
|
+
}
|
|
827
943
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
944
|
+
let templateId = options.template;
|
|
945
|
+
if (!templateId) {
|
|
946
|
+
if (templates_default.length === 1) {
|
|
947
|
+
templateId = templates_default[0].id;
|
|
948
|
+
} else {
|
|
949
|
+
const selected = await p4.select({
|
|
950
|
+
message: "Select a template",
|
|
951
|
+
options: templates_default.map((t, index) => ({
|
|
952
|
+
value: t.id,
|
|
953
|
+
label: index === 0 ? `${t.label} (Recommended)` : t.label
|
|
954
|
+
}))
|
|
955
|
+
});
|
|
956
|
+
if (p4.isCancel(selected)) {
|
|
957
|
+
p4.cancel("Operation cancelled");
|
|
958
|
+
process.exit(0);
|
|
839
959
|
}
|
|
840
|
-
|
|
960
|
+
templateId = selected;
|
|
841
961
|
}
|
|
842
|
-
});
|
|
843
|
-
if (p4.isCancel(name)) {
|
|
844
|
-
p4.cancel("Operation cancelled");
|
|
845
|
-
process.exit(0);
|
|
846
962
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
process.exit(1);
|
|
963
|
+
const template = templates_default.find(
|
|
964
|
+
(t) => t.id === templateId
|
|
965
|
+
);
|
|
966
|
+
if (options.ref) {
|
|
967
|
+
template.repository.ref = options.ref;
|
|
853
968
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
templateId = templates_default[0].id;
|
|
969
|
+
await createProject({ template, projectName, selectedAgents });
|
|
970
|
+
} catch (error) {
|
|
971
|
+
if (error instanceof Error) {
|
|
972
|
+
p4.log.error(`Error: ${error.message}`);
|
|
859
973
|
} else {
|
|
860
|
-
|
|
861
|
-
message: "Select a template",
|
|
862
|
-
options: templates_default.map((t, index) => ({
|
|
863
|
-
value: t.id,
|
|
864
|
-
label: index === 0 ? `${t.label} (Recommended)` : t.label
|
|
865
|
-
}))
|
|
866
|
-
});
|
|
867
|
-
if (p4.isCancel(selected)) {
|
|
868
|
-
p4.cancel("Operation cancelled");
|
|
869
|
-
process.exit(0);
|
|
870
|
-
}
|
|
871
|
-
templateId = selected;
|
|
974
|
+
p4.log.error(`Unknown error: ${String(error)}`);
|
|
872
975
|
}
|
|
976
|
+
process.exit(1);
|
|
873
977
|
}
|
|
874
|
-
const template = templates_default.find(
|
|
875
|
-
(t) => t.id === templateId
|
|
876
|
-
);
|
|
877
|
-
if (options.ref) {
|
|
878
|
-
template.repository.ref = options.ref;
|
|
879
|
-
}
|
|
880
|
-
p4.note(`Template: ${template.label}
|
|
881
|
-
App name: ${appName}`);
|
|
882
|
-
await createApp({ template, appName, selectedAgents });
|
|
883
|
-
} catch (error) {
|
|
884
|
-
if (error instanceof Error) {
|
|
885
|
-
p4.log.error(`Error: ${error.message}`);
|
|
886
|
-
} else {
|
|
887
|
-
p4.log.error(`Unknown error: ${String(error)}`);
|
|
888
|
-
}
|
|
889
|
-
process.exit(1);
|
|
890
978
|
}
|
|
891
|
-
|
|
979
|
+
);
|
|
892
980
|
agentsCommand(program);
|
|
893
981
|
program.showHelpAfterError();
|
|
894
982
|
program.showSuggestionAfterError(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drupal-canvas/create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "CLI to scaffold a codebase for working with Drupal Canvas Code Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"cross-spawn": "^7.0.6",
|
|
33
33
|
"picocolors": "^1.1.1",
|
|
34
34
|
"rimraf": "^6.1.2",
|
|
35
|
-
"simple-git": "^3.
|
|
35
|
+
"simple-git": "^3.36.0",
|
|
36
36
|
"string-width": "^7.2.0",
|
|
37
37
|
"validate-npm-package-name": "^7.0.0"
|
|
38
38
|
},
|