@drupal-canvas/create 1.0.0 → 1.1.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/dist/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import chalk from 'chalk';
3
3
  import { Command } from 'commander';
4
- import * as p2 from '@clack/prompts';
5
- import { readFile, writeFile } from 'fs/promises';
6
- import { join } from 'path';
4
+ import * as p3 from '@clack/prompts';
5
+ import { readFile, writeFile, access, readdir, mkdir, symlink } from 'fs/promises';
6
+ import { join, dirname, relative } from 'path';
7
7
  import spawn from 'cross-spawn';
8
8
  import { rimraf } from 'rimraf';
9
+ import { platform } from 'os';
10
+ import * as readline from 'readline';
11
+ import { Writable } from 'stream';
12
+ import pc from 'picocolors';
9
13
  import { simpleGit } from 'simple-git';
10
14
  import validate from 'validate-npm-package-name';
11
15
 
@@ -15,7 +19,7 @@ var templates_default = [
15
19
  id: "acquia-nebula",
16
20
  label: "acquia/nebula",
17
21
  repository: {
18
- url: "git@github.com:acquia/nebula.git",
22
+ url: "https://github.com/acquia/nebula.git",
19
23
  ref: "main"
20
24
  }
21
25
  },
@@ -23,12 +27,534 @@ var templates_default = [
23
27
  id: "balintbrews-canvas-starter",
24
28
  label: "balintbrews/canvas-starter",
25
29
  repository: {
26
- url: "git@github.com:balintbrews/canvas-starter.git",
30
+ url: "https://github.com/balintbrews/canvas-starter.git",
27
31
  ref: "main"
28
32
  }
29
33
  }
30
34
  ];
31
35
 
36
+ // src/lib/agents.ts
37
+ var agents = {
38
+ amp: {
39
+ displayName: "Amp",
40
+ skillsDir: ".agents/skills"
41
+ },
42
+ antigravity: {
43
+ displayName: "Antigravity",
44
+ skillsDir: ".agent/skills"
45
+ },
46
+ augment: {
47
+ displayName: "Augment",
48
+ skillsDir: ".augment/skills"
49
+ },
50
+ "claude-code": {
51
+ displayName: "Claude Code",
52
+ skillsDir: ".claude/skills"
53
+ },
54
+ openclaw: {
55
+ displayName: "OpenClaw",
56
+ skillsDir: "skills"
57
+ },
58
+ cline: {
59
+ displayName: "Cline",
60
+ skillsDir: ".cline/skills"
61
+ },
62
+ codebuddy: {
63
+ displayName: "CodeBuddy",
64
+ skillsDir: ".codebuddy/skills"
65
+ },
66
+ codex: {
67
+ displayName: "Codex",
68
+ skillsDir: ".agents/skills"
69
+ },
70
+ "command-code": {
71
+ displayName: "Command Code",
72
+ skillsDir: ".commandcode/skills"
73
+ },
74
+ continue: {
75
+ displayName: "Continue",
76
+ skillsDir: ".continue/skills"
77
+ },
78
+ crush: {
79
+ displayName: "Crush",
80
+ skillsDir: ".crush/skills"
81
+ },
82
+ cursor: {
83
+ displayName: "Cursor",
84
+ skillsDir: ".cursor/skills"
85
+ },
86
+ droid: {
87
+ displayName: "Droid",
88
+ skillsDir: ".factory/skills"
89
+ },
90
+ "gemini-cli": {
91
+ displayName: "Gemini CLI",
92
+ skillsDir: ".agents/skills"
93
+ },
94
+ "github-copilot": {
95
+ displayName: "GitHub Copilot",
96
+ skillsDir: ".agents/skills"
97
+ },
98
+ goose: {
99
+ displayName: "Goose",
100
+ skillsDir: ".goose/skills"
101
+ },
102
+ junie: {
103
+ displayName: "Junie",
104
+ skillsDir: ".junie/skills"
105
+ },
106
+ "iflow-cli": {
107
+ displayName: "iFlow CLI",
108
+ skillsDir: ".iflow/skills"
109
+ },
110
+ kilo: {
111
+ displayName: "Kilo Code",
112
+ skillsDir: ".kilocode/skills"
113
+ },
114
+ "kimi-cli": {
115
+ displayName: "Kimi Code CLI",
116
+ skillsDir: ".agents/skills"
117
+ },
118
+ "kiro-cli": {
119
+ displayName: "Kiro CLI",
120
+ skillsDir: ".kiro/skills"
121
+ },
122
+ kode: {
123
+ displayName: "Kode",
124
+ skillsDir: ".kode/skills"
125
+ },
126
+ mcpjam: {
127
+ displayName: "MCPJam",
128
+ skillsDir: ".mcpjam/skills"
129
+ },
130
+ "mistral-vibe": {
131
+ displayName: "Mistral Vibe",
132
+ skillsDir: ".vibe/skills"
133
+ },
134
+ mux: {
135
+ displayName: "Mux",
136
+ skillsDir: ".mux/skills"
137
+ },
138
+ opencode: {
139
+ displayName: "OpenCode",
140
+ skillsDir: ".agents/skills"
141
+ },
142
+ openhands: {
143
+ displayName: "OpenHands",
144
+ skillsDir: ".openhands/skills"
145
+ },
146
+ pi: {
147
+ displayName: "Pi",
148
+ skillsDir: ".pi/skills"
149
+ },
150
+ qoder: {
151
+ displayName: "Qoder",
152
+ skillsDir: ".qoder/skills"
153
+ },
154
+ "qwen-code": {
155
+ displayName: "Qwen Code",
156
+ skillsDir: ".qwen/skills"
157
+ },
158
+ replit: {
159
+ displayName: "Replit",
160
+ skillsDir: ".agents/skills",
161
+ showInUniversalList: false
162
+ },
163
+ roo: {
164
+ displayName: "Roo Code",
165
+ skillsDir: ".roo/skills"
166
+ },
167
+ trae: {
168
+ displayName: "Trae",
169
+ skillsDir: ".trae/skills"
170
+ },
171
+ "trae-cn": {
172
+ displayName: "Trae CN",
173
+ skillsDir: ".trae/skills"
174
+ },
175
+ windsurf: {
176
+ displayName: "Windsurf",
177
+ skillsDir: ".windsurf/skills"
178
+ },
179
+ zencoder: {
180
+ displayName: "Zencoder",
181
+ skillsDir: ".zencoder/skills"
182
+ },
183
+ neovate: {
184
+ displayName: "Neovate",
185
+ skillsDir: ".neovate/skills"
186
+ },
187
+ pochi: {
188
+ displayName: "Pochi",
189
+ skillsDir: ".pochi/skills"
190
+ },
191
+ adal: {
192
+ displayName: "AdaL",
193
+ skillsDir: ".adal/skills"
194
+ }
195
+ };
196
+ Object.entries(agents).map(
197
+ ([value, config]) => ({
198
+ value,
199
+ label: config.displayName,
200
+ hint: config.skillsDir
201
+ })
202
+ );
203
+ function getUniversalAgents() {
204
+ return Object.entries(agents).filter(
205
+ ([_, config]) => config.skillsDir === ".agents/skills" && config.showInUniversalList !== false
206
+ ).map(([type]) => type);
207
+ }
208
+ function getNonUniversalAgents() {
209
+ return Object.entries(agents).filter(([_, config]) => config.skillsDir !== ".agents/skills").map(([type]) => type);
210
+ }
211
+ function isUniversalAgent(type) {
212
+ return agents[type].skillsDir === ".agents/skills";
213
+ }
214
+ var silentOutput = new Writable({
215
+ write(_chunk, _encoding, callback) {
216
+ callback();
217
+ }
218
+ });
219
+ var S_STEP_ACTIVE = pc.green("\u25C6");
220
+ var S_STEP_CANCEL = pc.red("\u25A0");
221
+ var S_STEP_SUBMIT = pc.green("\u25C7");
222
+ var S_RADIO_ACTIVE = pc.green("\u25CF");
223
+ var S_RADIO_INACTIVE = pc.dim("\u25CB");
224
+ var S_CHECKBOX_LOCKED = pc.green("\u2713");
225
+ var S_BAR = pc.dim("\u2502");
226
+ var S_BAR_H = pc.dim("\u2500");
227
+ var cancelSymbol = /* @__PURE__ */ Symbol("cancel");
228
+ async function searchMultiselect(options) {
229
+ const {
230
+ message,
231
+ items,
232
+ maxVisible = 8,
233
+ initialSelected = [],
234
+ required = false,
235
+ lockedSection
236
+ } = options;
237
+ return new Promise((resolve) => {
238
+ const rl = readline.createInterface({
239
+ input: process.stdin,
240
+ output: silentOutput,
241
+ terminal: false
242
+ });
243
+ if (process.stdin.isTTY) {
244
+ process.stdin.setRawMode(true);
245
+ }
246
+ readline.emitKeypressEvents(process.stdin, rl);
247
+ let query = "";
248
+ let cursor = 0;
249
+ const selected = new Set(initialSelected);
250
+ let lastRenderHeight = 0;
251
+ const lockedValues = lockedSection ? lockedSection.items.map((i) => i.value) : [];
252
+ const filter = (item, q) => {
253
+ if (!q) return true;
254
+ const lowerQ = q.toLowerCase();
255
+ return item.label.toLowerCase().includes(lowerQ) || String(item.value).toLowerCase().includes(lowerQ);
256
+ };
257
+ const getFiltered = () => {
258
+ return items.filter((item) => filter(item, query));
259
+ };
260
+ const clearRender = () => {
261
+ if (lastRenderHeight > 0) {
262
+ process.stdout.write(`\x1B[${lastRenderHeight}A`);
263
+ for (let i = 0; i < lastRenderHeight; i++) {
264
+ process.stdout.write("\x1B[2K\x1B[1B");
265
+ }
266
+ process.stdout.write(`\x1B[${lastRenderHeight}A`);
267
+ }
268
+ };
269
+ const render = (state = "active") => {
270
+ clearRender();
271
+ const lines = [];
272
+ const filtered = getFiltered();
273
+ const icon = state === "active" ? S_STEP_ACTIVE : state === "cancel" ? S_STEP_CANCEL : S_STEP_SUBMIT;
274
+ lines.push(`${icon} ${pc.bold(message)}`);
275
+ if (state === "active") {
276
+ if (lockedSection && lockedSection.items.length > 0) {
277
+ lines.push(`${S_BAR}`);
278
+ lines.push(
279
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold(lockedSection.title)} ${S_BAR_H.repeat(30)}`
280
+ );
281
+ for (const item of lockedSection.items) {
282
+ lines.push(`${S_BAR} ${S_CHECKBOX_LOCKED} ${item.label}`);
283
+ }
284
+ lines.push(`${S_BAR}`);
285
+ lines.push(
286
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold("Other agents")} ${S_BAR_H.repeat(34)}`
287
+ );
288
+ }
289
+ const searchLine = `${S_BAR} ${pc.dim("Search:")} ${query}${pc.inverse(" ")}`;
290
+ lines.push(searchLine);
291
+ lines.push(
292
+ `${S_BAR} ${pc.dim("\u2191\u2193 move, space select, enter confirm")}`
293
+ );
294
+ lines.push(`${S_BAR}`);
295
+ const visibleStart = Math.max(
296
+ 0,
297
+ Math.min(
298
+ cursor - Math.floor(maxVisible / 2),
299
+ filtered.length - maxVisible
300
+ )
301
+ );
302
+ const visibleEnd = Math.min(filtered.length, visibleStart + maxVisible);
303
+ const visibleItems = filtered.slice(visibleStart, visibleEnd);
304
+ if (filtered.length === 0) {
305
+ lines.push(`${S_BAR} ${pc.dim("No matches found")}`);
306
+ } else {
307
+ for (let i = 0; i < visibleItems.length; i++) {
308
+ const item = visibleItems[i];
309
+ const actualIndex = visibleStart + i;
310
+ const isSelected = selected.has(item.value);
311
+ const isCursor = actualIndex === cursor;
312
+ const radio = isSelected ? S_RADIO_ACTIVE : S_RADIO_INACTIVE;
313
+ const label = isCursor ? pc.underline(item.label) : item.label;
314
+ const hint = item.hint ? pc.dim(` (${item.hint})`) : "";
315
+ const prefix = isCursor ? pc.cyan("\u276F") : " ";
316
+ lines.push(`${S_BAR} ${prefix} ${radio} ${label}${hint}`);
317
+ }
318
+ const hiddenBefore = visibleStart;
319
+ const hiddenAfter = filtered.length - visibleEnd;
320
+ if (hiddenBefore > 0 || hiddenAfter > 0) {
321
+ const parts = [];
322
+ if (hiddenBefore > 0) parts.push(`\u2191 ${hiddenBefore} more`);
323
+ if (hiddenAfter > 0) parts.push(`\u2193 ${hiddenAfter} more`);
324
+ lines.push(`${S_BAR} ${pc.dim(parts.join(" "))}`);
325
+ }
326
+ }
327
+ lines.push(`${S_BAR}`);
328
+ const allSelectedLabels = [
329
+ ...lockedSection ? lockedSection.items.map((i) => i.label) : [],
330
+ ...items.filter((item) => selected.has(item.value)).map((item) => item.label)
331
+ ];
332
+ if (allSelectedLabels.length === 0) {
333
+ lines.push(`${S_BAR} ${pc.dim("Selected: (none)")}`);
334
+ } else {
335
+ const summary = allSelectedLabels.length <= 3 ? allSelectedLabels.join(", ") : `${allSelectedLabels.slice(0, 3).join(", ")} +${allSelectedLabels.length - 3} more`;
336
+ lines.push(`${S_BAR} ${pc.green("Selected:")} ${summary}`);
337
+ }
338
+ lines.push(`${pc.dim("\u2514")}`);
339
+ } else if (state === "submit") {
340
+ const allSelectedLabels = [
341
+ ...lockedSection ? lockedSection.items.map((i) => i.label) : [],
342
+ ...items.filter((item) => selected.has(item.value)).map((item) => item.label)
343
+ ];
344
+ lines.push(`${S_BAR} ${pc.dim(allSelectedLabels.join(", "))}`);
345
+ } else if (state === "cancel") {
346
+ lines.push(`${S_BAR} ${pc.strikethrough(pc.dim("Cancelled"))}`);
347
+ }
348
+ process.stdout.write(lines.join("\n") + "\n");
349
+ lastRenderHeight = lines.length;
350
+ };
351
+ const cleanup = () => {
352
+ process.stdin.removeListener("keypress", keypressHandler);
353
+ if (process.stdin.isTTY) {
354
+ process.stdin.setRawMode(false);
355
+ }
356
+ rl.close();
357
+ };
358
+ const submit = () => {
359
+ if (required && selected.size === 0 && lockedValues.length === 0) {
360
+ return;
361
+ }
362
+ render("submit");
363
+ cleanup();
364
+ resolve([...lockedValues, ...Array.from(selected)]);
365
+ };
366
+ const cancel2 = () => {
367
+ render("cancel");
368
+ cleanup();
369
+ resolve(cancelSymbol);
370
+ };
371
+ const keypressHandler = (_str, key) => {
372
+ if (!key) return;
373
+ const filtered = getFiltered();
374
+ if (key.name === "return") {
375
+ submit();
376
+ return;
377
+ }
378
+ if (key.name === "escape" || key.ctrl && key.name === "c") {
379
+ cancel2();
380
+ return;
381
+ }
382
+ if (key.name === "up") {
383
+ cursor = Math.max(0, cursor - 1);
384
+ render();
385
+ return;
386
+ }
387
+ if (key.name === "down") {
388
+ cursor = Math.min(filtered.length - 1, cursor + 1);
389
+ render();
390
+ return;
391
+ }
392
+ if (key.name === "space") {
393
+ const item = filtered[cursor];
394
+ if (item) {
395
+ if (selected.has(item.value)) {
396
+ selected.delete(item.value);
397
+ } else {
398
+ selected.add(item.value);
399
+ }
400
+ }
401
+ render();
402
+ return;
403
+ }
404
+ if (key.name === "backspace") {
405
+ query = query.slice(0, -1);
406
+ cursor = 0;
407
+ render();
408
+ return;
409
+ }
410
+ if (key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1) {
411
+ query += key.sequence;
412
+ cursor = 0;
413
+ render();
414
+ return;
415
+ }
416
+ };
417
+ process.stdin.on("keypress", keypressHandler);
418
+ render();
419
+ });
420
+ }
421
+
422
+ // src/lib/text.ts
423
+ function pluralize(word, count) {
424
+ return count === 1 ? word : `${word}s`;
425
+ }
426
+
427
+ // src/lib/agent-skills-setup.ts
428
+ var DEFAULT_SKILLS_DIR = ".agents/skills";
429
+ async function setupAgentSkills(projectDir, options = {}) {
430
+ const info = options.onInfo ?? p3.log.info;
431
+ const warning = options.onWarning ?? p3.log.warn;
432
+ try {
433
+ const canonicalSkillsDir = join(projectDir, DEFAULT_SKILLS_DIR);
434
+ const hasSkillsDir = await pathExists(canonicalSkillsDir);
435
+ if (!hasSkillsDir) {
436
+ return;
437
+ }
438
+ const skillNames = await discoverSkillNames(canonicalSkillsDir);
439
+ if (skillNames.length === 0) {
440
+ info(
441
+ "No skills found in .agents/skills. Skipping agent compatibility setup."
442
+ );
443
+ return;
444
+ }
445
+ const promptForAgents = options.promptForAgents ?? defaultPromptForAgents;
446
+ const selected = await promptForAgents();
447
+ if (p3.isCancel(selected) || typeof selected === "symbol") {
448
+ info("Skipped agent compatibility setup.");
449
+ return;
450
+ }
451
+ if (selected.length === 0) {
452
+ info("No agents selected. Skipping agent compatibility setup.");
453
+ return;
454
+ }
455
+ const nonUniversalAgents = selected.filter(
456
+ (agent) => !isUniversalAgent(agent)
457
+ );
458
+ if (nonUniversalAgents.length === 0) {
459
+ info("Selected agents already use .agents/skills. No symlinks needed.");
460
+ return;
461
+ }
462
+ const results = await createAgentSkillSymlinks({
463
+ projectDir,
464
+ canonicalSkillsDir,
465
+ skillNames,
466
+ selectedAgents: nonUniversalAgents
467
+ });
468
+ const selectedAgentNames = selected.map((agent) => agents[agent].displayName).join(", ");
469
+ info(`Agent skill support selected: ${selectedAgentNames}.`);
470
+ if (results.created.length > 0) {
471
+ info(
472
+ `Created compatibility ${pluralize("symlink", results.created.length)} (${skillNames.length} ${pluralize("skill", skillNames.length)} \xD7 ${nonUniversalAgents.length} ${pluralize("agent", nonUniversalAgents.length)}).`
473
+ );
474
+ }
475
+ if (results.skipped.length > 0) {
476
+ warning(
477
+ `Skipped ${results.skipped.length} existing ${pluralize("path", results.skipped.length)}: ${results.skipped.map((entry) => entry.linkPath).join(", ")}`
478
+ );
479
+ }
480
+ if (results.failed.length > 0) {
481
+ warning(
482
+ `Failed to create ${results.failed.length} ${pluralize("symlink", results.failed.length)}: ${results.failed.map((entry) => `${entry.linkPath} (${entry.reason})`).join(", ")}`
483
+ );
484
+ }
485
+ } catch (error) {
486
+ const warning2 = options.onWarning ?? p3.log.warn;
487
+ const message = error instanceof Error ? error.message : "Unknown error during agent compatibility setup";
488
+ warning2(`Agent compatibility setup skipped: ${message}`);
489
+ }
490
+ }
491
+ async function defaultPromptForAgents() {
492
+ const universalAgents = getUniversalAgents();
493
+ const otherAgents = getNonUniversalAgents();
494
+ const selected = await searchMultiselect({
495
+ message: "Which coding agents should this codebase support?",
496
+ items: otherAgents.map((agent) => ({
497
+ value: agent,
498
+ label: agents[agent].displayName,
499
+ hint: agents[agent].skillsDir
500
+ })),
501
+ lockedSection: {
502
+ title: "Universal (.agents/skills)",
503
+ items: universalAgents.map((agent) => ({
504
+ value: agent,
505
+ label: agents[agent].displayName
506
+ }))
507
+ }
508
+ });
509
+ if (selected === cancelSymbol) {
510
+ return selected;
511
+ }
512
+ return selected;
513
+ }
514
+ async function discoverSkillNames(canonicalSkillsDir) {
515
+ const entries = await readdir(canonicalSkillsDir, { withFileTypes: true });
516
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((a, b) => a.localeCompare(b));
517
+ }
518
+ async function createAgentSkillSymlinks(options) {
519
+ const created = [];
520
+ const skipped = [];
521
+ const failed = [];
522
+ for (const agent of options.selectedAgents) {
523
+ const agentSkillsDir = join(options.projectDir, agents[agent].skillsDir);
524
+ for (const skill of options.skillNames) {
525
+ const targetPath = join(options.canonicalSkillsDir, skill);
526
+ const linkPath = join(agentSkillsDir, skill);
527
+ await mkdir(dirname(linkPath), { recursive: true });
528
+ if (await pathExists(linkPath)) {
529
+ skipped.push({ agent, skill, linkPath });
530
+ continue;
531
+ }
532
+ try {
533
+ const relativeTarget = relative(dirname(linkPath), targetPath);
534
+ const symlinkType = platform() === "win32" ? "junction" : void 0;
535
+ await symlink(relativeTarget, linkPath, symlinkType);
536
+ created.push({ agent, skill, linkPath });
537
+ } catch (error) {
538
+ failed.push({
539
+ agent,
540
+ skill,
541
+ linkPath,
542
+ reason: error instanceof Error ? error.message : "Unknown error"
543
+ });
544
+ }
545
+ }
546
+ }
547
+ return { created, skipped, failed };
548
+ }
549
+ async function pathExists(path) {
550
+ try {
551
+ await access(path);
552
+ return true;
553
+ } catch {
554
+ return false;
555
+ }
556
+ }
557
+
32
558
  // src/lib/detect-package-manager.ts
33
559
  function detectPackageManager() {
34
560
  const userAgent = process.env.npm_config_user_agent || "";
@@ -47,7 +573,7 @@ function detectPackageManager() {
47
573
  // package.json
48
574
  var package_default = {
49
575
  name: "@drupal-canvas/create",
50
- version: "1.0.0",
576
+ version: "1.0.1",
51
577
  description: "CLI to scaffold a codebase for working with Drupal Canvas Code Components"};
52
578
 
53
579
  // src/lib/meta-info.ts
@@ -60,8 +586,9 @@ var use_git_default = (baseDir) => simpleGit(baseDir).env({ ...process.env, GIT_
60
586
  // src/create.ts
61
587
  async function createApp(ctx) {
62
588
  const { template, appName } = ctx;
589
+ const projectDir = `${process.cwd()}/${appName}`;
63
590
  try {
64
- const s1 = p2.spinner();
591
+ const s1 = p3.spinner();
65
592
  s1.start("Fetching initial codebase");
66
593
  const hasCommitSHARef = /^[a-f0-9]{40}$/i.test(template.repository.ref);
67
594
  const git = use_git_default();
@@ -72,13 +599,13 @@ async function createApp(ctx) {
72
599
  options["--branch"] = template.repository.ref;
73
600
  }
74
601
  await git.clone(template.repository.url, appName, options);
75
- const gitAppDir = use_git_default(`${process.cwd()}/${appName}`);
602
+ const gitAppDir = use_git_default(projectDir);
76
603
  if (hasCommitSHARef) {
77
604
  await gitAppDir.fetch("origin", template.repository.ref);
78
605
  await gitAppDir.checkout(template.repository.ref);
79
606
  }
80
- await rimraf(`${process.cwd()}/${appName}/.git`);
81
- const packageJsonPath = join(process.cwd(), appName, "package.json");
607
+ await rimraf(`${projectDir}/.git`);
608
+ const packageJsonPath = join(projectDir, "package.json");
82
609
  const packageJsonContent = await readFile(packageJsonPath, "utf-8");
83
610
  const packageJson = JSON.parse(packageJsonContent);
84
611
  packageJson.name = appName;
@@ -87,7 +614,8 @@ async function createApp(ctx) {
87
614
  JSON.stringify(packageJson, null, 2) + "\n"
88
615
  );
89
616
  s1.stop(chalk.green("Fetched initial codebase"));
90
- const s2 = p2.spinner();
617
+ await setupAgentSkills(projectDir);
618
+ const s2 = p3.spinner();
91
619
  const packageManager = detectPackageManager();
92
620
  s2.start(`Installing dependencies using ${packageManager}`);
93
621
  await new Promise((resolve, reject) => {
@@ -121,7 +649,7 @@ ${stderrOutput}` : ""}`
121
649
  });
122
650
  });
123
651
  s2.stop(chalk.green("Installed dependencies"));
124
- const s3 = p2.spinner();
652
+ const s3 = p3.spinner();
125
653
  s3.start("Preparing your repository");
126
654
  await git.init(["--initial-branch=main", appName]);
127
655
  await gitAppDir.add(["--all"]);
@@ -132,14 +660,14 @@ Template repository: ${template.repository.url}
132
660
  Ref: ${template.repository.ref}`
133
661
  );
134
662
  s3.stop(chalk.green("Prepared repository"));
135
- p2.note(`$ cd ${appName}
663
+ p3.note(`$ cd ${appName}
136
664
  $ ${packageManager} run dev`, "Get started");
137
- p2.outro("\u{1F680} App created successfully");
665
+ p3.outro("\u{1F680} App created successfully");
138
666
  } catch (error) {
139
667
  if (error instanceof Error) {
140
- p2.log.error(`Error: ${error.message}`);
668
+ p3.log.error(`Error: ${error.message}`);
141
669
  } else {
142
- p2.log.error(`Unknown error: ${String(error)}`);
670
+ p3.log.error(`Unknown error: ${String(error)}`);
143
671
  }
144
672
  process.exit(1);
145
673
  }
@@ -169,7 +697,7 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
169
697
  "-r, --ref <ref>",
170
698
  "use Git ref when cloning template repository (for example, branch name or tag)"
171
699
  ).action(async (appNameArg, options) => {
172
- p2.intro(chalk.bold("Drupal Canvas Create"));
700
+ p3.intro(chalk.bold("Drupal Canvas Create"));
173
701
  try {
174
702
  if (options.template) {
175
703
  const template2 = templates_default.find(
@@ -195,13 +723,13 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
195
723
  }
196
724
  });
197
725
  } else if (!template2) {
198
- p2.log.error(`Template "${options.template}" not found`);
726
+ p3.log.error(`Template "${options.template}" not found`);
199
727
  process.exit(1);
200
728
  }
201
729
  }
202
730
  let appName = appNameArg;
203
731
  if (!appName) {
204
- const name = await p2.text({
732
+ const name = await p3.text({
205
733
  message: "Enter the app name",
206
734
  initialValue: "my-canvas-app",
207
735
  validate: (value) => {
@@ -213,15 +741,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
213
741
  return;
214
742
  }
215
743
  });
216
- if (p2.isCancel(name)) {
217
- p2.cancel("Operation cancelled");
744
+ if (p3.isCancel(name)) {
745
+ p3.cancel("Operation cancelled");
218
746
  process.exit(0);
219
747
  }
220
748
  appName = name;
221
749
  } else {
222
750
  const { valid, problems } = validateName(appName);
223
751
  if (!valid) {
224
- p2.log.error(`Invalid app name: ${problems.join(", ")}`);
752
+ p3.log.error(`Invalid app name: ${problems.join(", ")}`);
225
753
  process.exit(1);
226
754
  }
227
755
  }
@@ -230,15 +758,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
230
758
  if (templates_default.length === 1) {
231
759
  templateId = templates_default[0].id;
232
760
  } else {
233
- const selected = await p2.select({
761
+ const selected = await p3.select({
234
762
  message: "Select a template",
235
763
  options: templates_default.map((t, index) => ({
236
764
  value: t.id,
237
765
  label: index === 0 ? `${t.label} (Recommended)` : t.label
238
766
  }))
239
767
  });
240
- if (p2.isCancel(selected)) {
241
- p2.cancel("Operation cancelled");
768
+ if (p3.isCancel(selected)) {
769
+ p3.cancel("Operation cancelled");
242
770
  process.exit(0);
243
771
  }
244
772
  templateId = selected;
@@ -250,14 +778,14 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
250
778
  if (options.ref) {
251
779
  template.repository.ref = options.ref;
252
780
  }
253
- p2.note(`Template: ${template.label}
781
+ p3.note(`Template: ${template.label}
254
782
  App name: ${appName}`);
255
783
  await createApp({ template, appName });
256
784
  } catch (error) {
257
785
  if (error instanceof Error) {
258
- p2.log.error(`Error: ${error.message}`);
786
+ p3.log.error(`Error: ${error.message}`);
259
787
  } else {
260
- p2.log.error(`Unknown error: ${String(error)}`);
788
+ p3.log.error(`Unknown error: ${String(error)}`);
261
789
  }
262
790
  process.exit(1);
263
791
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@drupal-canvas/create",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI to scaffold a codebase for working with Drupal Canvas Code Components",
5
- "license": "GPL-2.0-or-later",
5
+ "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://git.drupalcode.org/project/canvas.git"
@@ -30,20 +30,25 @@
30
30
  "chalk": "^5.6.2",
31
31
  "commander": "^14.0.2",
32
32
  "cross-spawn": "^7.0.6",
33
- "rimraf": "^6.1.0",
33
+ "picocolors": "^1.1.1",
34
+ "rimraf": "^6.1.2",
34
35
  "simple-git": "^3.30.0",
36
+ "string-width": "^7.2.0",
35
37
  "validate-npm-package-name": "^7.0.0"
36
38
  },
37
39
  "devDependencies": {
38
40
  "@types/cross-spawn": "^6.0.6",
39
41
  "@types/validate-npm-package-name": "^4.0.2",
40
42
  "tsup": "^8.5.1",
41
- "typescript": "^5.9.3"
43
+ "typescript": "^5.9.3",
44
+ "vitest": "^4.0.18"
42
45
  },
43
46
  "scripts": {
44
47
  "start": "node dist/index.js",
45
48
  "build": "NODE_ENV=production tsup",
46
49
  "dev": "NODE_ENV=development tsup --watch",
47
- "type-check": "tsc --noEmit --pretty"
50
+ "type-check": "tsc --noEmit --pretty",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest watch"
48
53
  }
49
54
  }
package/templates.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "acquia-nebula",
4
4
  "label": "acquia/nebula",
5
5
  "repository": {
6
- "url": "git@github.com:acquia/nebula.git",
6
+ "url": "https://github.com/acquia/nebula.git",
7
7
  "ref": "main"
8
8
  }
9
9
  },
@@ -11,7 +11,7 @@
11
11
  "id": "balintbrews-canvas-starter",
12
12
  "label": "balintbrews/canvas-starter",
13
13
  "repository": {
14
- "url": "git@github.com:balintbrews/canvas-starter.git",
14
+ "url": "https://github.com/balintbrews/canvas-starter.git",
15
15
  "ref": "main"
16
16
  }
17
17
  }