@cedarjs/cli 5.0.0-canary.2379 → 5.0.0-canary.2382
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.
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import * as parser from "@babel/parser";
|
|
4
|
+
import * as t from "@babel/types";
|
|
3
5
|
import execa from "execa";
|
|
4
6
|
import { Listr } from "listr2";
|
|
7
|
+
import * as recast from "recast";
|
|
5
8
|
import { getConfigPath, getConfig } from "@cedarjs/project-config";
|
|
6
9
|
import { getPaths, writeFilesTask } from "../../../../lib/index.js";
|
|
7
10
|
const updateApiURLTask = (apiUrl) => {
|
|
@@ -84,6 +87,91 @@ const verifyUDSetupTask = () => {
|
|
|
84
87
|
}
|
|
85
88
|
};
|
|
86
89
|
};
|
|
90
|
+
function posToIndex(str, line, column) {
|
|
91
|
+
const lines = str.split("\n");
|
|
92
|
+
let index = 0;
|
|
93
|
+
for (let i = 0; i < line - 1; i++) {
|
|
94
|
+
index += lines[i].length + 1;
|
|
95
|
+
}
|
|
96
|
+
return index + column;
|
|
97
|
+
}
|
|
98
|
+
function insertPluginsBeforeCedar({ content, pluginCodes }) {
|
|
99
|
+
const ast = recast.parse(content, {
|
|
100
|
+
parser: {
|
|
101
|
+
parse(source) {
|
|
102
|
+
return parser.parse(source, {
|
|
103
|
+
sourceType: "module",
|
|
104
|
+
plugins: ["typescript", "jsx"]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const defaultExport = ast.program.body.find(
|
|
110
|
+
(node) => t.isExportDefaultDeclaration(node) && t.isCallExpression(node.declaration) && t.isIdentifier(node.declaration.callee) && node.declaration.callee.name === "defineConfig"
|
|
111
|
+
);
|
|
112
|
+
if (!defaultExport) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const configArg = defaultExport.declaration.arguments[0];
|
|
116
|
+
if (!t.isObjectExpression(configArg)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const pluginsProp = configArg.properties.find(
|
|
120
|
+
(prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "plugins" && t.isArrayExpression(prop.value)
|
|
121
|
+
);
|
|
122
|
+
if (!pluginsProp) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const elements = pluginsProp.value.elements;
|
|
126
|
+
const cedarIndex = elements.findIndex(
|
|
127
|
+
(el) => t.isCallExpression(el) && t.isIdentifier(el.callee) && el.callee.name === "cedar"
|
|
128
|
+
);
|
|
129
|
+
if (cedarIndex === -1) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const cedarNode = elements[cedarIndex];
|
|
133
|
+
const arrayNode = pluginsProp.value;
|
|
134
|
+
const isInline = cedarNode.loc.start.line === arrayNode.loc.start.line;
|
|
135
|
+
if (isInline) {
|
|
136
|
+
const startPos = posToIndex(
|
|
137
|
+
content,
|
|
138
|
+
arrayNode.loc.start.line,
|
|
139
|
+
arrayNode.loc.start.column
|
|
140
|
+
);
|
|
141
|
+
const endPos = posToIndex(
|
|
142
|
+
content,
|
|
143
|
+
arrayNode.loc.end.line,
|
|
144
|
+
arrayNode.loc.end.column
|
|
145
|
+
);
|
|
146
|
+
const precedingText = content.slice(0, startPos);
|
|
147
|
+
const followingText = content.slice(endPos);
|
|
148
|
+
const existingCodes = elements.map(
|
|
149
|
+
(el) => content.slice(
|
|
150
|
+
posToIndex(content, el.loc.start.line, el.loc.start.column),
|
|
151
|
+
posToIndex(content, el.loc.end.line, el.loc.end.column)
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
const lines2 = content.split("\n");
|
|
155
|
+
const pluginsLine = pluginsProp.loc.start.line;
|
|
156
|
+
const pluginsIndent = lines2[pluginsLine - 1].match(/^\s*/)[0];
|
|
157
|
+
const elemIndent = pluginsIndent + " ";
|
|
158
|
+
const allCodes = [...existingCodes];
|
|
159
|
+
allCodes.splice(cedarIndex, 0, ...pluginCodes);
|
|
160
|
+
const multiline = [
|
|
161
|
+
"[",
|
|
162
|
+
...allCodes.map((code) => `${elemIndent}${code},`),
|
|
163
|
+
`${pluginsIndent}]`
|
|
164
|
+
].join("\n");
|
|
165
|
+
return precedingText + multiline + followingText;
|
|
166
|
+
}
|
|
167
|
+
const cedarLine = cedarNode.loc.start.line;
|
|
168
|
+
const insertPos = posToIndex(content, cedarLine, 0);
|
|
169
|
+
const lines = content.split("\n");
|
|
170
|
+
const indent = lines[cedarLine - 1].match(/^\s*/)[0];
|
|
171
|
+
const insertion = pluginCodes.map((code) => `${indent}${code},
|
|
172
|
+
`).join("");
|
|
173
|
+
return content.slice(0, insertPos) + insertion + content.slice(insertPos);
|
|
174
|
+
}
|
|
87
175
|
const addToGitIgnoreTask = ({ paths }) => {
|
|
88
176
|
return {
|
|
89
177
|
title: "Updating .gitignore...",
|
|
@@ -125,6 +213,7 @@ export {
|
|
|
125
213
|
addToDotEnvTask,
|
|
126
214
|
addToGitIgnoreTask,
|
|
127
215
|
getUserApiUrl,
|
|
216
|
+
insertPluginsBeforeCedar,
|
|
128
217
|
preRequisiteCheckTask,
|
|
129
218
|
updateApiURLTask,
|
|
130
219
|
verifyUDSetupTask
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../../../../lib/index.js";
|
|
11
11
|
import {
|
|
12
12
|
addFilesTask,
|
|
13
|
+
insertPluginsBeforeCedar,
|
|
13
14
|
updateApiURLTask,
|
|
14
15
|
verifyUDSetupTask
|
|
15
16
|
} from "../helpers/index.js";
|
|
@@ -87,17 +88,16 @@ ${result}`;
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
if (!content.includes("netlifyCompat(")) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
91
|
+
const result = insertPluginsBeforeCedar({
|
|
92
|
+
content,
|
|
93
|
+
pluginCodes: [
|
|
94
|
+
"netlify({ build: { enabled: true } })",
|
|
95
|
+
"netlifyCompat()"
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
if (result) {
|
|
99
|
+
content = result;
|
|
100
|
+
}
|
|
101
101
|
}
|
|
102
102
|
fs.writeFileSync(viteConfigPath, content);
|
|
103
103
|
}
|
|
@@ -9,7 +9,11 @@ import {
|
|
|
9
9
|
printSetupNotes,
|
|
10
10
|
writeFile
|
|
11
11
|
} from "../../../../lib/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
insertPluginsBeforeCedar,
|
|
14
|
+
updateApiURLTask,
|
|
15
|
+
verifyUDSetupTask
|
|
16
|
+
} from "../helpers/index.js";
|
|
13
17
|
async function handler({ force, ud }) {
|
|
14
18
|
recordTelemetryAttributes({
|
|
15
19
|
command: "setup deploy vercel",
|
|
@@ -67,16 +71,13 @@ function addVercelPluginToViteConfigTask() {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
if (!content.includes("vercel(")) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
${indent}${cedarCall}`;
|
|
78
|
-
}
|
|
79
|
-
);
|
|
74
|
+
const result = insertPluginsBeforeCedar({
|
|
75
|
+
content,
|
|
76
|
+
pluginCodes: ["vercel()"]
|
|
77
|
+
});
|
|
78
|
+
if (result) {
|
|
79
|
+
content = result;
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
82
|
fs.writeFileSync(viteConfigPath, content);
|
|
82
83
|
}
|
|
@@ -8,7 +8,7 @@ publish = "web/dist"
|
|
|
8
8
|
NODE_VERSION = "24"
|
|
9
9
|
|
|
10
10
|
[functions]
|
|
11
|
-
directory = "api/dist/
|
|
11
|
+
directory = "api/dist/ud"
|
|
12
12
|
|
|
13
13
|
# To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use
|
|
14
14
|
# \`netlify link\` to connect your local project to a site on Netlify. Then run
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2382",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.3",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "5.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.2382",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2382",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2382",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2382",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2382",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2382",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2382",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2382",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2382",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2382",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2382",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.0",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|