@drupal-canvas/create 1.5.0 → 1.7.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 +82 -8
- package/dist/index.js +405 -64
- package/docs/experimental.md +61 -0
- package/package.json +4 -2
- package/templates.json +39 -6
package/README.md
CHANGED
|
@@ -28,30 +28,86 @@ You can also provide the project name as an argument:
|
|
|
28
28
|
npx @drupal-canvas/create@latest my-project
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
Experimental features are documented in
|
|
32
|
+
[`docs/experimental.md`](docs/experimental.md).
|
|
33
|
+
|
|
31
34
|
### Options
|
|
32
35
|
|
|
33
|
-
| Option
|
|
34
|
-
|
|
|
35
|
-
| `--template -t`
|
|
36
|
-
| `--ref <ref>`
|
|
37
|
-
| `--agents -a`
|
|
36
|
+
| Option | Description |
|
|
37
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `--template -t` | Template to use when scaffolding the project. One of the predefined templates in `templates.json` or a URL to a custom template's Git repository. |
|
|
39
|
+
| `--ref <ref>` | Custom Git ref to use when cloning the template repository. For example, a branch name or a tag. |
|
|
40
|
+
| `--agents -a` | Comma-separated list of additional agents to support, or `none` to skip compatibility symlink creation. |
|
|
41
|
+
| `--site-name <name>` | Site name to slugify and suggest as the interactive project name. |
|
|
42
|
+
| `--site-url <url>` | Canvas site URL to write to the generated `.env`. Takes precedence over `CANVAS_SITE_URL`. |
|
|
43
|
+
|
|
44
|
+
### Interactive and non-interactive input
|
|
45
|
+
|
|
46
|
+
A run is interactive when both standard input and output are attached to a
|
|
47
|
+
terminal. Non-interactive runs never prompt.
|
|
48
|
+
|
|
49
|
+
| Input | CLI input | Interactive when omitted | Non-interactive when omitted |
|
|
50
|
+
| ------------ | --------------------------------- | ------------------------------------------------ | --------------------------------------- |
|
|
51
|
+
| Project name | Positional `[project-name]` | Prompted | Error |
|
|
52
|
+
| Template | `--template`, `-t` | Default frontend selected automatically | Default frontend selected automatically |
|
|
53
|
+
| Site name | `--site-name` | Used to suggest the project name | Ignored |
|
|
54
|
+
| Site URL | `--site-url` or `CANVAS_SITE_URL` | Prompted | Optional; no `.env` when omitted |
|
|
55
|
+
| Git ref | `--ref`, `-r` | Template default applies | Template default applies |
|
|
56
|
+
| Agents | `--agents`, `-a` | Prompted when the template includes agent skills | Optional; compatibility is skipped |
|
|
38
57
|
|
|
39
58
|
### Example
|
|
40
59
|
|
|
41
60
|
```bash
|
|
42
|
-
npx @drupal-canvas/create@latest my-project --template
|
|
61
|
+
npx @drupal-canvas/create@latest my-project --template default
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The previous `acquia-nebula` template ID remains supported as an alias.
|
|
65
|
+
|
|
66
|
+
Use a site name to suggest an editable project name when the positional project
|
|
67
|
+
name is omitted:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx @drupal-canvas/create@latest --site-name 'My Drupal Site'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Provide the Canvas site URL with a flag:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx @drupal-canvas/create@latest my-project \
|
|
77
|
+
--site-url https://canvas.example.com
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The `CANVAS_SITE_URL` environment variable can be used instead. The flag takes
|
|
81
|
+
precedence when both are provided:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
CANVAS_SITE_URL='https://canvas.example.com' \
|
|
85
|
+
npx @drupal-canvas/create@latest my-project
|
|
43
86
|
```
|
|
44
87
|
|
|
88
|
+
When neither value is provided, interactive runs prompt for the site URL.
|
|
89
|
+
Non-interactive runs continue without creating `.env`. When a URL is provided
|
|
90
|
+
and the template includes `.env.example`, the CLI copies it to `.env` and
|
|
91
|
+
updates or appends `CANVAS_SITE_URL`. Otherwise, it creates a new `.env`. If
|
|
92
|
+
`.env` already exists, the CLI adds or fills `CANVAS_SITE_URL`; when a non-empty
|
|
93
|
+
value is already configured, it keeps that value. The CLI prints a message for
|
|
94
|
+
each outcome and ensures `.env` is listed in `.gitignore`.
|
|
95
|
+
|
|
96
|
+
Non-interactive runs require a positional project name. When multiple templates
|
|
97
|
+
are enabled, `--template` is also required. The `--site-name` option does not
|
|
98
|
+
replace the positional project name in this mode. Missing site URLs and agent
|
|
99
|
+
selections remain optional and do not prompt.
|
|
100
|
+
|
|
45
101
|
Explicitly skip additional agent compatibility symlinks:
|
|
46
102
|
|
|
47
103
|
```bash
|
|
48
|
-
npx @drupal-canvas/create@latest my-project --template
|
|
104
|
+
npx @drupal-canvas/create@latest my-project --template default --agents none
|
|
49
105
|
```
|
|
50
106
|
|
|
51
107
|
Provide additional agent compatibility symlinks without prompting:
|
|
52
108
|
|
|
53
109
|
```bash
|
|
54
|
-
npx @drupal-canvas/create@latest my-project --template
|
|
110
|
+
npx @drupal-canvas/create@latest my-project --template default --agents claude-code,roo
|
|
55
111
|
```
|
|
56
112
|
|
|
57
113
|
If `--agents` is omitted, the CLI keeps the current interactive prompt on TTY
|
|
@@ -86,6 +142,24 @@ Drupal Canvas Create is designed to be easily extendable with new templates.
|
|
|
86
142
|
references a Git repository that will be cloned to provide the initial codebase.
|
|
87
143
|
To add a template, edit `templates.json` in the package root.
|
|
88
144
|
|
|
145
|
+
A repository can contain multiple templates. Set the optional repository `path`
|
|
146
|
+
to use a directory within the cloned repository as the project root:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"id": "company-starter",
|
|
151
|
+
"label": "company/canvas-starter",
|
|
152
|
+
"repository": {
|
|
153
|
+
"url": "https://github.com/company/canvas-templates.git",
|
|
154
|
+
"ref": "main",
|
|
155
|
+
"path": "templates/starter"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The path must identify a directory within the repository. Files outside that
|
|
161
|
+
directory are not included in the created project.
|
|
162
|
+
|
|
89
163
|
### Working with the codebase
|
|
90
164
|
|
|
91
165
|
First, build the project:
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalk2 from 'chalk';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import * as
|
|
5
|
-
import { readFile, writeFile, access, readdir, mkdir, symlink } from 'fs/promises';
|
|
4
|
+
import * as p5 from '@clack/prompts';
|
|
5
|
+
import { mkdtemp, readFile, writeFile, lstat, rename, access, readdir, mkdir, symlink } from 'fs/promises';
|
|
6
6
|
import { platform } from 'os';
|
|
7
|
-
import { join,
|
|
7
|
+
import { join, resolve, relative, sep, isAbsolute, dirname } from 'path';
|
|
8
8
|
import * as readline from 'readline';
|
|
9
9
|
import { Writable } from 'stream';
|
|
10
10
|
import pc from 'picocolors';
|
|
11
11
|
import spawn from 'cross-spawn';
|
|
12
12
|
import { rimraf } from 'rimraf';
|
|
13
13
|
import { simpleGit } from 'simple-git';
|
|
14
|
+
import slugify from '@sindresorhus/slugify';
|
|
14
15
|
import validate from 'validate-npm-package-name';
|
|
15
16
|
|
|
16
17
|
// templates.json
|
|
17
18
|
var templates_default = [
|
|
18
19
|
{
|
|
19
|
-
id: "
|
|
20
|
-
|
|
20
|
+
id: "default",
|
|
21
|
+
aliases: ["acquia-nebula"],
|
|
22
|
+
label: "Default (Canvas-rendered React)",
|
|
21
23
|
repository: {
|
|
22
24
|
url: "https://github.com/acquia/nebula.git",
|
|
23
25
|
ref: "main"
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
{
|
|
27
|
-
id: "
|
|
28
|
-
label: "
|
|
29
|
+
id: "nextjs",
|
|
30
|
+
label: "Next.js",
|
|
31
|
+
experimental: true,
|
|
29
32
|
repository: {
|
|
30
|
-
url: "https://github.com/
|
|
31
|
-
ref: "main"
|
|
33
|
+
url: "https://github.com/drupal-canvas/headless-templates.git",
|
|
34
|
+
ref: "main",
|
|
35
|
+
path: "nextjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "astro",
|
|
40
|
+
label: "Astro",
|
|
41
|
+
experimental: true,
|
|
42
|
+
repository: {
|
|
43
|
+
url: "https://github.com/drupal-canvas/headless-templates.git",
|
|
44
|
+
ref: "main",
|
|
45
|
+
path: "astro"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "nuxt",
|
|
50
|
+
label: "Nuxt",
|
|
51
|
+
experimental: true,
|
|
52
|
+
repository: {
|
|
53
|
+
url: "https://github.com/drupal-canvas/headless-templates.git",
|
|
54
|
+
ref: "main",
|
|
55
|
+
path: "nuxt"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "tanstack-start",
|
|
60
|
+
label: "TanStack Start",
|
|
61
|
+
experimental: true,
|
|
62
|
+
repository: {
|
|
63
|
+
url: "https://github.com/drupal-canvas/headless-templates.git",
|
|
64
|
+
ref: "main",
|
|
65
|
+
path: "tanstack-start"
|
|
32
66
|
}
|
|
33
67
|
}
|
|
34
68
|
];
|
|
@@ -344,7 +378,7 @@ async function searchMultiselect(options) {
|
|
|
344
378
|
required = false,
|
|
345
379
|
lockedSection
|
|
346
380
|
} = options;
|
|
347
|
-
return new Promise((
|
|
381
|
+
return new Promise((resolve2) => {
|
|
348
382
|
const rl = readline.createInterface({
|
|
349
383
|
input: process.stdin,
|
|
350
384
|
output: silentOutput,
|
|
@@ -472,12 +506,12 @@ async function searchMultiselect(options) {
|
|
|
472
506
|
}
|
|
473
507
|
render("submit");
|
|
474
508
|
cleanup();
|
|
475
|
-
|
|
509
|
+
resolve2([...lockedValues, ...Array.from(selected)]);
|
|
476
510
|
};
|
|
477
511
|
const cancel2 = () => {
|
|
478
512
|
render("cancel");
|
|
479
513
|
cleanup();
|
|
480
|
-
|
|
514
|
+
resolve2(cancelSymbol);
|
|
481
515
|
};
|
|
482
516
|
const keypressHandler = (_str, key) => {
|
|
483
517
|
if (!key) return;
|
|
@@ -538,8 +572,8 @@ function pluralize(word, count) {
|
|
|
538
572
|
// src/lib/agent-skills-setup.ts
|
|
539
573
|
var DEFAULT_SKILLS_DIR = ".agents/skills";
|
|
540
574
|
async function setupAgentSkills(projectDir, options = {}) {
|
|
541
|
-
const info = options.onInfo ??
|
|
542
|
-
const warning = options.onWarning ??
|
|
575
|
+
const info = options.onInfo ?? p5.log.info;
|
|
576
|
+
const warning = options.onWarning ?? p5.log.warn;
|
|
543
577
|
const interactive = options.interactive ?? true;
|
|
544
578
|
const hasExplicitSelection = options.selectedAgents !== void 0;
|
|
545
579
|
try {
|
|
@@ -565,7 +599,7 @@ async function setupAgentSkills(projectDir, options = {}) {
|
|
|
565
599
|
const promptForAgents = options.promptForAgents ?? defaultPromptForAgents;
|
|
566
600
|
selected = await promptForAgents();
|
|
567
601
|
}
|
|
568
|
-
if (
|
|
602
|
+
if (p5.isCancel(selected) || typeof selected === "symbol") {
|
|
569
603
|
info("Skipped compatibility setup.");
|
|
570
604
|
return;
|
|
571
605
|
}
|
|
@@ -610,7 +644,7 @@ ${nonUniversalAgents.map(
|
|
|
610
644
|
);
|
|
611
645
|
}
|
|
612
646
|
} catch (error) {
|
|
613
|
-
const warning2 = options.onWarning ??
|
|
647
|
+
const warning2 = options.onWarning ?? p5.log.warn;
|
|
614
648
|
const message = error instanceof Error ? error.message : "Unknown error during compatibility setup";
|
|
615
649
|
warning2(`Compatibility setup skipped: ${message}`);
|
|
616
650
|
}
|
|
@@ -618,7 +652,7 @@ ${nonUniversalAgents.map(
|
|
|
618
652
|
async function defaultPromptForAgents() {
|
|
619
653
|
const universalAgents = getUniversalAgents();
|
|
620
654
|
const additionalAgents = getNonUniversalAgents();
|
|
621
|
-
|
|
655
|
+
p5.log.message("");
|
|
622
656
|
const selected = await searchMultiselect({
|
|
623
657
|
message: "Which AI coding agents should this codebase support?",
|
|
624
658
|
items: additionalAgents.map((agent) => ({
|
|
@@ -682,6 +716,16 @@ async function pathExists(path) {
|
|
|
682
716
|
return false;
|
|
683
717
|
}
|
|
684
718
|
}
|
|
719
|
+
var DRUPAL_BLUE = "#009CDE";
|
|
720
|
+
var DRUPAL_NAVY = "#12285F";
|
|
721
|
+
var DRUPAL_PURPLE = "#CCBAF4";
|
|
722
|
+
function commandIntro(commandName) {
|
|
723
|
+
return `${chalk2.bgHex(DRUPAL_BLUE).hex(DRUPAL_NAVY)(" Drupal Canvas ")}${chalk2.bgHex(DRUPAL_PURPLE).hex(DRUPAL_NAVY)(` ${commandName} `)}`;
|
|
724
|
+
}
|
|
725
|
+
function printCommandIntro(commandName) {
|
|
726
|
+
console.log();
|
|
727
|
+
p5.intro(commandIntro(commandName));
|
|
728
|
+
}
|
|
685
729
|
|
|
686
730
|
// src/agents.ts
|
|
687
731
|
function agentsCommand(program2) {
|
|
@@ -691,7 +735,7 @@ function agentsCommand(program2) {
|
|
|
691
735
|
"[agents]",
|
|
692
736
|
'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
|
|
693
737
|
).action(async (agentsArg) => {
|
|
694
|
-
|
|
738
|
+
printCommandIntro("create agents");
|
|
695
739
|
try {
|
|
696
740
|
const selectedAgents = parseAgentSelection(agentsArg, "agents");
|
|
697
741
|
const projectDir = process.cwd();
|
|
@@ -699,12 +743,12 @@ function agentsCommand(program2) {
|
|
|
699
743
|
selectedAgents,
|
|
700
744
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
701
745
|
});
|
|
702
|
-
|
|
746
|
+
p5.outro("Agent compatibility setup complete.");
|
|
703
747
|
} catch (error) {
|
|
704
748
|
if (error instanceof Error) {
|
|
705
|
-
|
|
749
|
+
p5.log.error(`Error: ${error.message}`);
|
|
706
750
|
} else {
|
|
707
|
-
|
|
751
|
+
p5.log.error(`Unknown error: ${String(error)}`);
|
|
708
752
|
}
|
|
709
753
|
process.exit(1);
|
|
710
754
|
}
|
|
@@ -729,13 +773,177 @@ function detectPackageManager() {
|
|
|
729
773
|
// package.json
|
|
730
774
|
var package_default = {
|
|
731
775
|
name: "@drupal-canvas/create",
|
|
732
|
-
version: "1.
|
|
776
|
+
version: "1.7.0",
|
|
733
777
|
description: "CLI to scaffold a codebase for working with Drupal Canvas Code Components"};
|
|
734
778
|
|
|
735
779
|
// src/lib/meta-info.ts
|
|
736
780
|
var getName = () => package_default.name;
|
|
737
781
|
var getDescription = () => package_default.description;
|
|
738
782
|
var getVersion = () => package_default.version;
|
|
783
|
+
async function moveTemplateDirectory(repositoryDir, projectDir, repositoryPath) {
|
|
784
|
+
const templateDir = resolve(repositoryDir, repositoryPath);
|
|
785
|
+
const relativeTemplateDir = relative(repositoryDir, templateDir);
|
|
786
|
+
if (!relativeTemplateDir || relativeTemplateDir === ".." || relativeTemplateDir.startsWith(`..${sep}`) || isAbsolute(relativeTemplateDir)) {
|
|
787
|
+
throw new Error(
|
|
788
|
+
`Template repository path "${repositoryPath}" must be a relative path within the repository`
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
let templateStats;
|
|
792
|
+
try {
|
|
793
|
+
templateStats = await lstat(templateDir);
|
|
794
|
+
} catch (error) {
|
|
795
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
796
|
+
throw new Error(
|
|
797
|
+
`Template repository path "${repositoryPath}" does not exist`
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
throw error;
|
|
801
|
+
}
|
|
802
|
+
if (!templateStats.isDirectory()) {
|
|
803
|
+
throw new Error(
|
|
804
|
+
`Template repository path "${repositoryPath}" must point to a directory`
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
await lstat(projectDir);
|
|
809
|
+
throw new Error(`Project directory "${projectDir}" already exists`);
|
|
810
|
+
} catch (error) {
|
|
811
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") ; else {
|
|
812
|
+
throw error;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
await rename(templateDir, projectDir);
|
|
816
|
+
}
|
|
817
|
+
var ENV_FILENAME = ".env";
|
|
818
|
+
var ENV_EXAMPLE_FILENAME = ".env.example";
|
|
819
|
+
var ENV_VARIABLE = "CANVAS_SITE_URL";
|
|
820
|
+
function isNodeError(error) {
|
|
821
|
+
return error instanceof Error && "code" in error;
|
|
822
|
+
}
|
|
823
|
+
function validateSiteUrl(value) {
|
|
824
|
+
if (!value) return "Canvas site URL is required";
|
|
825
|
+
try {
|
|
826
|
+
const url = new URL(value);
|
|
827
|
+
if ((url.protocol === "http:" || url.protocol === "https:") && url.hostname) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
} catch {
|
|
831
|
+
}
|
|
832
|
+
return "Canvas site URL must be an http:// or https:// URL";
|
|
833
|
+
}
|
|
834
|
+
async function ensureEnvIsIgnored(projectDir) {
|
|
835
|
+
const gitignorePath = join(projectDir, ".gitignore");
|
|
836
|
+
let gitignore = "";
|
|
837
|
+
try {
|
|
838
|
+
gitignore = await readFile(gitignorePath, "utf-8");
|
|
839
|
+
} catch (error) {
|
|
840
|
+
if (!isNodeError(error) || error.code !== "ENOENT") {
|
|
841
|
+
throw error;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
const ignoresEnv = gitignore.split(/\r?\n/).some((line) => line.trim() === ENV_FILENAME);
|
|
845
|
+
if (ignoresEnv) return;
|
|
846
|
+
const separator = gitignore.length > 0 && !gitignore.endsWith("\n") ? "\n" : "";
|
|
847
|
+
await writeFile(
|
|
848
|
+
gitignorePath,
|
|
849
|
+
`${gitignore}${separator}${ENV_FILENAME}
|
|
850
|
+
`,
|
|
851
|
+
"utf-8"
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
async function readOptionalFile(path) {
|
|
855
|
+
try {
|
|
856
|
+
return await readFile(path, "utf-8");
|
|
857
|
+
} catch (error) {
|
|
858
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
throw error;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function splitEnv(content) {
|
|
865
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
866
|
+
const hasFinalEol = content.endsWith("\n");
|
|
867
|
+
const lines = content.split(/\r?\n/);
|
|
868
|
+
if (hasFinalEol) lines.pop();
|
|
869
|
+
return { lines, eol, hasFinalEol };
|
|
870
|
+
}
|
|
871
|
+
function joinEnv({ lines, eol, hasFinalEol }) {
|
|
872
|
+
return `${lines.join(eol)}${hasFinalEol ? eol : ""}`;
|
|
873
|
+
}
|
|
874
|
+
function findAssignments(lines) {
|
|
875
|
+
const assignmentPattern = new RegExp(
|
|
876
|
+
`^(\\s*(?:export\\s+)?${ENV_VARIABLE}\\s*=\\s*)(.*)$`
|
|
877
|
+
);
|
|
878
|
+
return lines.flatMap((line, index) => {
|
|
879
|
+
const match = line.match(assignmentPattern);
|
|
880
|
+
return match ? [{ index, prefix: match[1], value: match[2] }] : [];
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
function setAssignment(env, siteUrl, assignment) {
|
|
884
|
+
const value = `${ENV_VARIABLE}=${JSON.stringify(siteUrl)}`;
|
|
885
|
+
if (assignment) {
|
|
886
|
+
env.lines[assignment.index] = `${assignment.prefix}${JSON.stringify(siteUrl)}`;
|
|
887
|
+
} else if (env.lines.length === 1 && env.lines[0] === "") {
|
|
888
|
+
env.lines[0] = value;
|
|
889
|
+
} else {
|
|
890
|
+
env.lines.push(value);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
function createEnvFromExample(example, siteUrl) {
|
|
894
|
+
const env = splitEnv(example);
|
|
895
|
+
const assignments = findAssignments(env.lines);
|
|
896
|
+
if (assignments.length > 1) {
|
|
897
|
+
throw new Error(
|
|
898
|
+
`${ENV_EXAMPLE_FILENAME} contains more than one ${ENV_VARIABLE} assignment`
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
setAssignment(env, siteUrl, assignments[0]);
|
|
902
|
+
return joinEnv(env);
|
|
903
|
+
}
|
|
904
|
+
function hasConfiguredValue(assignment) {
|
|
905
|
+
const value = assignment.value.trim();
|
|
906
|
+
return value !== "" && value !== '""' && value !== "''" && !value.startsWith("#");
|
|
907
|
+
}
|
|
908
|
+
function updateExistingEnv(content, siteUrl) {
|
|
909
|
+
const env = splitEnv(content);
|
|
910
|
+
const assignments = findAssignments(env.lines);
|
|
911
|
+
const effectiveAssignment = assignments.at(-1);
|
|
912
|
+
if (effectiveAssignment && hasConfiguredValue(effectiveAssignment)) {
|
|
913
|
+
return { content, result: "existing-site-url" };
|
|
914
|
+
}
|
|
915
|
+
setAssignment(env, siteUrl, effectiveAssignment);
|
|
916
|
+
return { content: joinEnv(env), result: "configured-existing" };
|
|
917
|
+
}
|
|
918
|
+
async function writeSiteUrlEnv(projectDir, siteUrl) {
|
|
919
|
+
const validationError = validateSiteUrl(siteUrl);
|
|
920
|
+
if (validationError) throw new Error(validationError);
|
|
921
|
+
const envPath = join(projectDir, ENV_FILENAME);
|
|
922
|
+
const existingEnv = await readOptionalFile(envPath);
|
|
923
|
+
if (existingEnv !== void 0) {
|
|
924
|
+
const updated = updateExistingEnv(existingEnv, siteUrl);
|
|
925
|
+
await ensureEnvIsIgnored(projectDir);
|
|
926
|
+
if (updated.content !== existingEnv) {
|
|
927
|
+
await writeFile(envPath, updated.content, "utf-8");
|
|
928
|
+
}
|
|
929
|
+
return updated.result;
|
|
930
|
+
}
|
|
931
|
+
const example = await readOptionalFile(
|
|
932
|
+
join(projectDir, ENV_EXAMPLE_FILENAME)
|
|
933
|
+
);
|
|
934
|
+
const envContent = example === void 0 ? `${ENV_VARIABLE}=${JSON.stringify(siteUrl)}
|
|
935
|
+
` : createEnvFromExample(example, siteUrl);
|
|
936
|
+
await ensureEnvIsIgnored(projectDir);
|
|
937
|
+
try {
|
|
938
|
+
await writeFile(envPath, envContent, { encoding: "utf-8", flag: "wx" });
|
|
939
|
+
} catch (error) {
|
|
940
|
+
if (isNodeError(error) && error.code === "EEXIST") {
|
|
941
|
+
return writeSiteUrlEnv(projectDir, siteUrl);
|
|
942
|
+
}
|
|
943
|
+
throw error;
|
|
944
|
+
}
|
|
945
|
+
return example === void 0 ? "created" : "copied-example";
|
|
946
|
+
}
|
|
739
947
|
var GIT_TERMINAL_PROMPT = 0;
|
|
740
948
|
var unsafe = {
|
|
741
949
|
allowUnsafeEditor: true,
|
|
@@ -749,10 +957,10 @@ var use_git_default = (baseDir) => {
|
|
|
749
957
|
|
|
750
958
|
// src/create.ts
|
|
751
959
|
async function createProject(ctx) {
|
|
752
|
-
const { template, projectName, selectedAgents } = ctx;
|
|
960
|
+
const { template, projectName, siteUrl, selectedAgents, interactive } = ctx;
|
|
753
961
|
const projectDir = `${process.cwd()}/${projectName}`;
|
|
754
962
|
try {
|
|
755
|
-
const s1 =
|
|
963
|
+
const s1 = p5.spinner();
|
|
756
964
|
s1.start("Fetching template");
|
|
757
965
|
const hasCommitSHARef = /^[a-f0-9]{40}$/i.test(template.repository.ref);
|
|
758
966
|
const git = use_git_default();
|
|
@@ -762,13 +970,35 @@ async function createProject(ctx) {
|
|
|
762
970
|
if (template.repository.ref !== "HEAD" && !hasCommitSHARef) {
|
|
763
971
|
options["--branch"] = template.repository.ref;
|
|
764
972
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
await
|
|
973
|
+
const repositoryPath = template.repository.path;
|
|
974
|
+
let temporaryCloneDir;
|
|
975
|
+
let cloneDir = projectDir;
|
|
976
|
+
if (repositoryPath) {
|
|
977
|
+
temporaryCloneDir = await mkdtemp(
|
|
978
|
+
join(process.cwd(), ".canvas-template-")
|
|
979
|
+
);
|
|
980
|
+
cloneDir = temporaryCloneDir;
|
|
981
|
+
}
|
|
982
|
+
try {
|
|
983
|
+
await git.clone(template.repository.url, cloneDir, options);
|
|
984
|
+
const gitCloneDir = use_git_default(cloneDir);
|
|
985
|
+
if (hasCommitSHARef) {
|
|
986
|
+
await gitCloneDir.fetch("origin", template.repository.ref);
|
|
987
|
+
await gitCloneDir.checkout(template.repository.ref);
|
|
988
|
+
}
|
|
989
|
+
if (repositoryPath) {
|
|
990
|
+
await moveTemplateDirectory(cloneDir, projectDir, repositoryPath);
|
|
991
|
+
await rimraf(cloneDir);
|
|
992
|
+
temporaryCloneDir = void 0;
|
|
993
|
+
}
|
|
994
|
+
} catch (error) {
|
|
995
|
+
if (temporaryCloneDir) {
|
|
996
|
+
await rimraf(temporaryCloneDir);
|
|
997
|
+
}
|
|
998
|
+
throw error;
|
|
770
999
|
}
|
|
771
|
-
|
|
1000
|
+
const gitProjectDir = use_git_default(projectDir);
|
|
1001
|
+
await rimraf(join(projectDir, ".git"));
|
|
772
1002
|
const packageJsonPath = join(projectDir, "package.json");
|
|
773
1003
|
const packageJsonContent = await readFile(packageJsonPath, "utf-8");
|
|
774
1004
|
const packageJson = JSON.parse(packageJsonContent);
|
|
@@ -777,15 +1007,35 @@ async function createProject(ctx) {
|
|
|
777
1007
|
packageJsonPath,
|
|
778
1008
|
JSON.stringify(packageJson, null, 2) + "\n"
|
|
779
1009
|
);
|
|
1010
|
+
const siteUrlEnvResult = siteUrl ? await writeSiteUrlEnv(projectDir, siteUrl) : void 0;
|
|
780
1011
|
s1.stop(chalk2.green("Fetched template"));
|
|
1012
|
+
switch (siteUrlEnvResult) {
|
|
1013
|
+
case "created":
|
|
1014
|
+
p5.log.info("Created .env.");
|
|
1015
|
+
break;
|
|
1016
|
+
case "copied-example":
|
|
1017
|
+
p5.log.info("Created .env from .env.example.");
|
|
1018
|
+
break;
|
|
1019
|
+
case "configured-existing":
|
|
1020
|
+
p5.log.info("Updated .env with CANVAS_SITE_URL.");
|
|
1021
|
+
break;
|
|
1022
|
+
case "existing-site-url":
|
|
1023
|
+
p5.log.info("Kept existing CANVAS_SITE_URL in .env.");
|
|
1024
|
+
break;
|
|
1025
|
+
case void 0:
|
|
1026
|
+
p5.log.warn(
|
|
1027
|
+
"No site URL provided. Set CANVAS_SITE_URL in .env to connect the project to your Drupal site."
|
|
1028
|
+
);
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
781
1031
|
await setupAgentSkills(projectDir, {
|
|
782
1032
|
selectedAgents,
|
|
783
|
-
interactive
|
|
1033
|
+
interactive
|
|
784
1034
|
});
|
|
785
|
-
const s2 =
|
|
1035
|
+
const s2 = p5.spinner();
|
|
786
1036
|
const packageManager = detectPackageManager();
|
|
787
1037
|
s2.start(`Installing dependencies with ${packageManager}`);
|
|
788
|
-
await new Promise((
|
|
1038
|
+
await new Promise((resolve2, reject) => {
|
|
789
1039
|
const child = spawn(packageManager, ["install"], {
|
|
790
1040
|
cwd: `./${projectName}`,
|
|
791
1041
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -814,25 +1064,27 @@ ${stderrOutput}` : ""}`
|
|
|
814
1064
|
)
|
|
815
1065
|
);
|
|
816
1066
|
} else {
|
|
817
|
-
|
|
1067
|
+
resolve2();
|
|
818
1068
|
}
|
|
819
1069
|
});
|
|
820
1070
|
});
|
|
821
1071
|
s2.stop(chalk2.green(`Installed dependencies with ${packageManager}`));
|
|
822
|
-
const s3 =
|
|
1072
|
+
const s3 = p5.spinner();
|
|
823
1073
|
s3.start("Initializing Git repository");
|
|
824
1074
|
await git.init(["--initial-branch=main", projectName]);
|
|
825
1075
|
await gitProjectDir.add(["--all"]);
|
|
1076
|
+
const repositoryPathMessage = template.repository.path ? `
|
|
1077
|
+
Path: ${template.repository.path}` : "";
|
|
826
1078
|
await gitProjectDir.commit(
|
|
827
1079
|
`Init project using ${getName()}@${getVersion()}
|
|
828
1080
|
|
|
829
1081
|
Template repository: ${template.repository.url}
|
|
830
|
-
Ref: ${template.repository.ref}`
|
|
1082
|
+
Ref: ${template.repository.ref}${repositoryPathMessage}`
|
|
831
1083
|
);
|
|
832
1084
|
s3.stop(
|
|
833
1085
|
chalk2.green("Initialized Git repository on main with initial commit")
|
|
834
1086
|
);
|
|
835
|
-
|
|
1087
|
+
p5.note(
|
|
836
1088
|
`Created project in ./${projectName}
|
|
837
1089
|
|
|
838
1090
|
Next steps:
|
|
@@ -840,12 +1092,12 @@ Next steps:
|
|
|
840
1092
|
${packageManager} run dev`,
|
|
841
1093
|
"Get started"
|
|
842
1094
|
);
|
|
843
|
-
|
|
1095
|
+
p5.outro("Canvas project created successfully.");
|
|
844
1096
|
} catch (error) {
|
|
845
1097
|
if (error instanceof Error) {
|
|
846
|
-
|
|
1098
|
+
p5.log.error(`Error: ${error.message}`);
|
|
847
1099
|
} else {
|
|
848
|
-
|
|
1100
|
+
p5.log.error(`Unknown error: ${String(error)}`);
|
|
849
1101
|
}
|
|
850
1102
|
process.exit(1);
|
|
851
1103
|
}
|
|
@@ -864,6 +1116,38 @@ function validateName(name) {
|
|
|
864
1116
|
};
|
|
865
1117
|
}
|
|
866
1118
|
|
|
1119
|
+
// src/lib/slugify-project-name.ts
|
|
1120
|
+
var DEFAULT_PROJECT_NAME = "my-canvas-project";
|
|
1121
|
+
var MAX_PACKAGE_NAME_LENGTH = 214;
|
|
1122
|
+
function slugifyProjectName(siteName) {
|
|
1123
|
+
const slug = slugify(siteName).slice(0, MAX_PACKAGE_NAME_LENGTH).replace(/-+$/g, "");
|
|
1124
|
+
if (!slug || !validateName(slug).valid) {
|
|
1125
|
+
return DEFAULT_PROJECT_NAME;
|
|
1126
|
+
}
|
|
1127
|
+
return slug;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// src/lib/template-resolution.ts
|
|
1131
|
+
function resolveTemplate(templates, identifier) {
|
|
1132
|
+
return templates.find(
|
|
1133
|
+
(template) => template.id === identifier || template.aliases?.includes(identifier)
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
function assertUniqueTemplateIdentifiers(templates) {
|
|
1137
|
+
const identifiers = /* @__PURE__ */ new Map();
|
|
1138
|
+
for (const template of templates) {
|
|
1139
|
+
for (const identifier of [template.id, ...template.aliases ?? []]) {
|
|
1140
|
+
const existingTemplateId = identifiers.get(identifier);
|
|
1141
|
+
if (existingTemplateId) {
|
|
1142
|
+
throw new Error(
|
|
1143
|
+
`Template identifier "${identifier}" is used by both "${existingTemplateId}" and "${template.id}"`
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
identifiers.set(identifier, template.id);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
867
1151
|
// src/index.ts
|
|
868
1152
|
process.on("SIGINT", () => process.exit(0));
|
|
869
1153
|
process.on("SIGTERM", () => process.exit(0));
|
|
@@ -877,14 +1161,30 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
|
|
|
877
1161
|
).option(
|
|
878
1162
|
"-a, --agents <agents>",
|
|
879
1163
|
'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
|
|
1164
|
+
).option(
|
|
1165
|
+
"--experimental-headless",
|
|
1166
|
+
"enable experimental headless frontend templates"
|
|
1167
|
+
).option(
|
|
1168
|
+
"--site-name <name>",
|
|
1169
|
+
"use slugified site name as the suggested project name"
|
|
1170
|
+
).option(
|
|
1171
|
+
"--site-url <url>",
|
|
1172
|
+
"use Canvas site URL when configuring the project"
|
|
880
1173
|
).action(
|
|
881
1174
|
async (projectNameArg, options) => {
|
|
882
|
-
|
|
1175
|
+
printCommandIntro("create");
|
|
883
1176
|
try {
|
|
1177
|
+
const interactive = Boolean(
|
|
1178
|
+
process.stdin.isTTY && process.stdout.isTTY
|
|
1179
|
+
);
|
|
884
1180
|
const selectedAgents = parseAgentSelection(options.agents);
|
|
1181
|
+
const predefinedTemplates = templates_default;
|
|
1182
|
+
assertUniqueTemplateIdentifiers(predefinedTemplates);
|
|
1183
|
+
const availableTemplates = options.experimentalHeadless ? predefinedTemplates : predefinedTemplates.filter((template2) => !template2.experimental);
|
|
885
1184
|
if (options.template) {
|
|
886
|
-
const template2 =
|
|
887
|
-
|
|
1185
|
+
const template2 = resolveTemplate(
|
|
1186
|
+
predefinedTemplates,
|
|
1187
|
+
options.template
|
|
888
1188
|
);
|
|
889
1189
|
const isCustomRepositoryUrl = [
|
|
890
1190
|
// Remote repositories.
|
|
@@ -897,7 +1197,7 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
|
|
|
897
1197
|
"/"
|
|
898
1198
|
].some((prefix) => options.template?.startsWith(prefix));
|
|
899
1199
|
if (!template2 && isCustomRepositoryUrl) {
|
|
900
|
-
|
|
1200
|
+
predefinedTemplates.push({
|
|
901
1201
|
id: options.template,
|
|
902
1202
|
label: options.template,
|
|
903
1203
|
repository: {
|
|
@@ -906,20 +1206,24 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
|
|
|
906
1206
|
}
|
|
907
1207
|
});
|
|
908
1208
|
} else if (!template2) {
|
|
909
|
-
|
|
1209
|
+
p5.log.error(
|
|
910
1210
|
`Template "${options.template}" not found.
|
|
911
1211
|
|
|
912
1212
|
Available templates:
|
|
913
|
-
${
|
|
1213
|
+
${availableTemplates.map((availableTemplate) => `- ${availableTemplate.id}`).join("\n")}`
|
|
914
1214
|
);
|
|
915
1215
|
process.exit(1);
|
|
916
1216
|
}
|
|
917
1217
|
}
|
|
918
1218
|
let projectName = projectNameArg;
|
|
919
1219
|
if (!projectName) {
|
|
920
|
-
|
|
1220
|
+
if (!interactive) {
|
|
1221
|
+
p5.log.error("Project name is required in a non-interactive run.");
|
|
1222
|
+
process.exit(1);
|
|
1223
|
+
}
|
|
1224
|
+
const name = await p5.text({
|
|
921
1225
|
message: "Enter the project name",
|
|
922
|
-
initialValue:
|
|
1226
|
+
initialValue: options.siteName === void 0 ? DEFAULT_PROJECT_NAME : slugifyProjectName(options.siteName),
|
|
923
1227
|
validate: (value) => {
|
|
924
1228
|
if (!value) return "Project name is required";
|
|
925
1229
|
const { valid, problems } = validateName(value);
|
|
@@ -929,49 +1233,86 @@ ${templates_default.map((availableTemplate) => `- ${availableTemplate.id}`).join
|
|
|
929
1233
|
return;
|
|
930
1234
|
}
|
|
931
1235
|
});
|
|
932
|
-
if (
|
|
933
|
-
|
|
1236
|
+
if (p5.isCancel(name)) {
|
|
1237
|
+
p5.cancel("Operation cancelled");
|
|
934
1238
|
process.exit(0);
|
|
935
1239
|
}
|
|
936
1240
|
projectName = name;
|
|
937
1241
|
} else {
|
|
938
1242
|
const { valid, problems } = validateName(projectName);
|
|
939
1243
|
if (!valid) {
|
|
940
|
-
|
|
1244
|
+
p5.log.error(`Invalid project name: ${problems.join(", ")}`);
|
|
1245
|
+
process.exit(1);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
let siteUrl = options.siteUrl ?? process.env.CANVAS_SITE_URL;
|
|
1249
|
+
if (!siteUrl?.trim()) {
|
|
1250
|
+
if (interactive) {
|
|
1251
|
+
const enteredSiteUrl = await p5.text({
|
|
1252
|
+
message: "Enter the Drupal site URL",
|
|
1253
|
+
validate: (value) => validateSiteUrl(value.trim())
|
|
1254
|
+
});
|
|
1255
|
+
if (p5.isCancel(enteredSiteUrl)) {
|
|
1256
|
+
p5.cancel("Operation cancelled");
|
|
1257
|
+
process.exit(0);
|
|
1258
|
+
}
|
|
1259
|
+
siteUrl = enteredSiteUrl;
|
|
1260
|
+
} else {
|
|
1261
|
+
siteUrl = void 0;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (siteUrl !== void 0) {
|
|
1265
|
+
siteUrl = siteUrl.trim();
|
|
1266
|
+
const siteUrlValidationError = validateSiteUrl(siteUrl);
|
|
1267
|
+
if (siteUrlValidationError) {
|
|
1268
|
+
p5.log.error(siteUrlValidationError);
|
|
941
1269
|
process.exit(1);
|
|
942
1270
|
}
|
|
943
1271
|
}
|
|
944
1272
|
let templateId = options.template;
|
|
945
1273
|
if (!templateId) {
|
|
946
|
-
if (
|
|
947
|
-
templateId =
|
|
1274
|
+
if (availableTemplates.length === 1) {
|
|
1275
|
+
templateId = availableTemplates[0].id;
|
|
948
1276
|
} else {
|
|
949
|
-
|
|
1277
|
+
if (!interactive) {
|
|
1278
|
+
p5.log.error(
|
|
1279
|
+
"Template is required in a non-interactive run. Use --template."
|
|
1280
|
+
);
|
|
1281
|
+
process.exit(1);
|
|
1282
|
+
}
|
|
1283
|
+
const selected = await p5.select({
|
|
950
1284
|
message: "Select a template",
|
|
951
|
-
options:
|
|
952
|
-
value:
|
|
953
|
-
label:
|
|
1285
|
+
options: availableTemplates.map((template2) => ({
|
|
1286
|
+
value: template2.id,
|
|
1287
|
+
label: template2.label
|
|
954
1288
|
}))
|
|
955
1289
|
});
|
|
956
|
-
if (
|
|
957
|
-
|
|
1290
|
+
if (p5.isCancel(selected)) {
|
|
1291
|
+
p5.cancel("Operation cancelled");
|
|
958
1292
|
process.exit(0);
|
|
959
1293
|
}
|
|
960
1294
|
templateId = selected;
|
|
961
1295
|
}
|
|
962
1296
|
}
|
|
963
|
-
const template =
|
|
964
|
-
|
|
1297
|
+
const template = resolveTemplate(
|
|
1298
|
+
predefinedTemplates,
|
|
1299
|
+
templateId
|
|
965
1300
|
);
|
|
966
1301
|
if (options.ref) {
|
|
967
1302
|
template.repository.ref = options.ref;
|
|
968
1303
|
}
|
|
969
|
-
await createProject({
|
|
1304
|
+
await createProject({
|
|
1305
|
+
template,
|
|
1306
|
+
projectName,
|
|
1307
|
+
siteUrl,
|
|
1308
|
+
selectedAgents,
|
|
1309
|
+
interactive
|
|
1310
|
+
});
|
|
970
1311
|
} catch (error) {
|
|
971
1312
|
if (error instanceof Error) {
|
|
972
|
-
|
|
1313
|
+
p5.log.error(`Error: ${error.message}`);
|
|
973
1314
|
} else {
|
|
974
|
-
|
|
1315
|
+
p5.log.error(`Unknown error: ${String(error)}`);
|
|
975
1316
|
}
|
|
976
1317
|
process.exit(1);
|
|
977
1318
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Experimental features
|
|
2
|
+
|
|
3
|
+
Experimental features may change or be removed without notice.
|
|
4
|
+
|
|
5
|
+
## Headless frontend templates
|
|
6
|
+
|
|
7
|
+
Without `--experimental-headless`, the CLI automatically uses the default
|
|
8
|
+
frontend template when `--template` is omitted.
|
|
9
|
+
|
|
10
|
+
Pass `--experimental-headless` to show all frontend templates in one interactive
|
|
11
|
+
list:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @drupal-canvas/create@latest --experimental-headless
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
Select a template
|
|
19
|
+
Default frontend
|
|
20
|
+
Next.js
|
|
21
|
+
Astro
|
|
22
|
+
Nuxt
|
|
23
|
+
TanStack Start
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The available experimental template IDs are:
|
|
27
|
+
|
|
28
|
+
| Template ID | Label |
|
|
29
|
+
| ---------------- | -------------- |
|
|
30
|
+
| `nextjs` | Next.js |
|
|
31
|
+
| `astro` | Astro |
|
|
32
|
+
| `nuxt` | Nuxt |
|
|
33
|
+
| `tanstack-start` | TanStack Start |
|
|
34
|
+
|
|
35
|
+
The experimental flag is only needed for interactive discovery. An experimental
|
|
36
|
+
template ID can be provided directly without it:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @drupal-canvas/create@latest my-project \
|
|
40
|
+
--template nextjs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Non-interactive runs using `--experimental-headless` require both the positional
|
|
44
|
+
project name and `--template`, so they do not use the template prompt. Without
|
|
45
|
+
the flag, the default frontend is selected automatically.
|
|
46
|
+
|
|
47
|
+
Experimental templates set `experimental` in `templates.json`. They can share a
|
|
48
|
+
repository by setting a repository-relative `path`:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"id": "nextjs",
|
|
53
|
+
"label": "Next.js",
|
|
54
|
+
"experimental": true,
|
|
55
|
+
"repository": {
|
|
56
|
+
"url": "https://github.com/drupal-canvas/headless-templates.git",
|
|
57
|
+
"ref": "main",
|
|
58
|
+
"path": "nextjs"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drupal-canvas/create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "CLI to scaffold a codebase for working with Drupal Canvas Code Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
+
"docs",
|
|
16
17
|
"templates.json",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|
|
@@ -23,10 +24,11 @@
|
|
|
23
24
|
"create"
|
|
24
25
|
],
|
|
25
26
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
27
|
+
"node": ">=22.19.0 <23 || >=24.5.0"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@clack/prompts": "^0.11.0",
|
|
31
|
+
"@sindresorhus/slugify": "^3.0.0",
|
|
30
32
|
"chalk": "^5.6.2",
|
|
31
33
|
"commander": "^14.0.2",
|
|
32
34
|
"cross-spawn": "^7.0.6",
|
package/templates.json
CHANGED
|
@@ -1,18 +1,51 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"id": "
|
|
4
|
-
"
|
|
3
|
+
"id": "default",
|
|
4
|
+
"aliases": ["acquia-nebula"],
|
|
5
|
+
"label": "Default (Canvas-rendered React)",
|
|
5
6
|
"repository": {
|
|
6
7
|
"url": "https://github.com/acquia/nebula.git",
|
|
7
8
|
"ref": "main"
|
|
8
9
|
}
|
|
9
10
|
},
|
|
10
11
|
{
|
|
11
|
-
"id": "
|
|
12
|
-
"label": "
|
|
12
|
+
"id": "nextjs",
|
|
13
|
+
"label": "Next.js",
|
|
14
|
+
"experimental": true,
|
|
13
15
|
"repository": {
|
|
14
|
-
"url": "https://github.com/
|
|
15
|
-
"ref": "main"
|
|
16
|
+
"url": "https://github.com/drupal-canvas/headless-templates.git",
|
|
17
|
+
"ref": "main",
|
|
18
|
+
"path": "nextjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "astro",
|
|
23
|
+
"label": "Astro",
|
|
24
|
+
"experimental": true,
|
|
25
|
+
"repository": {
|
|
26
|
+
"url": "https://github.com/drupal-canvas/headless-templates.git",
|
|
27
|
+
"ref": "main",
|
|
28
|
+
"path": "astro"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "nuxt",
|
|
33
|
+
"label": "Nuxt",
|
|
34
|
+
"experimental": true,
|
|
35
|
+
"repository": {
|
|
36
|
+
"url": "https://github.com/drupal-canvas/headless-templates.git",
|
|
37
|
+
"ref": "main",
|
|
38
|
+
"path": "nuxt"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "tanstack-start",
|
|
43
|
+
"label": "TanStack Start",
|
|
44
|
+
"experimental": true,
|
|
45
|
+
"repository": {
|
|
46
|
+
"url": "https://github.com/drupal-canvas/headless-templates.git",
|
|
47
|
+
"ref": "main",
|
|
48
|
+
"path": "tanstack-start"
|
|
16
49
|
}
|
|
17
50
|
}
|
|
18
51
|
]
|