You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b18f5d6
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cli): template accepts an absolute path inside the project; outside, it names the command that works (#11793)
[fix] `astryx template <name> <path>` and `astryx template --cdn <path>` accept an absolute path inside the project root, also through a symlinked project folder. It is written exactly as its relative path. An absolute path outside the project is still refused with `ERR_PATH_TRAVERSAL`. For `astryx template <name> <path>`, the receipt says the path was written as its relative path (`data.givenPath` in `--json`), and the refusal names a command that writes inside the project (`astryx template <name> src/pages/<name>`, or `src/components/<name>` for a block) and the command that prints the source without writing anything. For `--cdn`, the receipt is unchanged, and the refusal names `astryx template --cdn cdn.template.html`.
[fix]`astryx template <name> <path>` and `astryx template --cdn <path>` accept an absolute path inside the project root, also through a symlinked project folder. It is written exactly as its relative path. An absolute path outside the project is still refused with `ERR_PATH_TRAVERSAL`. For `astryx template <name> <path>`, the receipt says the path was written as its relative path (`data.givenPath` in `--json`), and the refusal names a command that writes inside the project (`astryx template <name> src/pages/<name>`, or `src/components/<name>` for a block) and the command that prints the source without writing anything. For `--cdn`, the receipt is unchanged, and the refusal names `astryx template --cdn cdn.template.html`.
Copy file name to clipboardExpand all lines: packages/cli/api/template/template.doc.mjs
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ export const doc = {
89
89
name: 'options.targetPath',
90
90
type: 'string',
91
91
description:
92
-
'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy. '+
92
+
'Destination inside cwd to scaffold the template into: a relative path, or an absolute path inside cwd, which is written as its relative path and reported as data.givenPath. A path outside cwd is refused with ERR_PATH_TRAVERSAL. Its presence switches a named lookup into a copy. '+
93
93
"A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block's own file name for a block.",
94
94
},
95
95
{
@@ -125,7 +125,7 @@ export const doc = {
125
125
{
126
126
type: 'template.copy',
127
127
description:
128
-
'A receipt after scaffolding the template into the project: the template id, output directory, written file name, file count, `demoMediaReplaced` — how many Astryx demo media references were replaced with placeholders, `demoContentReplaced` — how many Astryx docs-only demo content elements were replaced with a `<Text>` placeholder, `notes` — setup notes naming what the template needs that the project lacks (missing packages, missing StyleX compiler; empty when satisfied), `missingPackages` — external package names the template imports that are not in the project, and `installCommand` — a ready-to-run install command with the detected package manager and workspace version ranges (null when nothing is missing, or when several lockfiles leave the package manager undetermined; `missingPackages` still names the packages).',
128
+
'A receipt after scaffolding the template into the project: the template id, output directory, written file name, file count, `givenPath` — the absolute path as given, present only when it was inside the project, `demoMediaReplaced` — how many Astryx demo media references were replaced with placeholders, `demoContentReplaced` — how many Astryx docs-only demo content elements were replaced with a `<Text>` placeholder, `notes` — setup notes naming what the template needs that the project lacks (missing packages, missing StyleX compiler; empty when satisfied), `missingPackages` — external package names the template imports that are not in the project, and `installCommand` — a ready-to-run install command with the detected package manager and workspace version ranges (null when nothing is missing, or when several lockfiles leave the package manager undetermined; `missingPackages` still names the packages).',
129
129
},
130
130
{
131
131
type: 'template.cdn',
@@ -152,7 +152,7 @@ export const doc = {
152
152
},
153
153
{
154
154
code: 'ERR_PATH_TRAVERSAL',
155
-
when: 'the copy target path is absolute or escapes the project root',
155
+
when: 'the copy target path is outside the project root',
Copy file name to clipboardExpand all lines: packages/cli/api/template/template.type.mjs
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,7 @@
86
86
* @property {string[]} data.notes Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Each note is one actionable line. Empty when the template needs nothing the project lacks.
87
87
* @property {string[]} data.missingPackages External package names the template imports that are not in the project's dependencies. Empty when none are missing.
88
88
* @property {string | null} data.installCommand A ready-to-run install command for the missing packages, using the project's package manager and the CLI workspace's version ranges. Null when no packages are missing, or when several lockfiles leave the package manager undetermined; missingPackages still names the packages.
89
+
* @property {string} [data.givenPath] The absolute path as given, present only when it named a place inside the project root. The write is the same as for its relative path: `outputDir` for a folder, or `outputDir` and `fileName` for a file.
89
90
* @property {TemplateIconsReport} [data.icons] Experimental, present only when the project sets `experimental.iconSet`: how the written file's icons follow the project's icon set, each icon `mapped` (source and target), a `placeholder`, or `kept`, the sets used with their licenses, and the icon-set state. It may change or be removed in a patch release.
Copy file name to clipboardExpand all lines: packages/cli/clients/cli/commands/template.doc.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ export const doc = {
36
36
param: 'options.targetPath',
37
37
required: false,
38
38
description:
39
-
'Where to scaffold the template, relative to the project root. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; '+
39
+
'Where to scaffold the template, inside the project root: a relative path, or an absolute path inside the project, which is written as its relative path. A path outside the project is refused. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; '+
40
40
"any other path is a directory, which receives page.tsx for a page template or the block's own file name for a block. "+
0 commit comments