@cedarjs/cli-helpers 6.0.0-canary.2771 → 6.0.0-canary.2773
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/lib/project.d.ts.map +1 -1
- package/dist/lib/project.js +2 -1
- package/package.json +14 -46
- package/dist/cjs/auth/authFiles.d.ts +0 -44
- package/dist/cjs/auth/authFiles.d.ts.map +0 -1
- package/dist/cjs/auth/authFiles.js +0 -109
- package/dist/cjs/auth/authTasks.d.ts +0 -49
- package/dist/cjs/auth/authTasks.d.ts.map +0 -1
- package/dist/cjs/auth/authTasks.js +0 -391
- package/dist/cjs/auth/setupHelpers.d.ts +0 -27
- package/dist/cjs/auth/setupHelpers.d.ts.map +0 -1
- package/dist/cjs/auth/setupHelpers.js +0 -141
- package/dist/cjs/index.d.ts +0 -12
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -52
- package/dist/cjs/lib/colors.d.ts +0 -24
- package/dist/cjs/lib/colors.d.ts.map +0 -1
- package/dist/cjs/lib/colors.js +0 -52
- package/dist/cjs/lib/index.d.ts +0 -22
- package/dist/cjs/lib/index.d.ts.map +0 -1
- package/dist/cjs/lib/index.js +0 -147
- package/dist/cjs/lib/installHelpers.d.ts +0 -17
- package/dist/cjs/lib/installHelpers.d.ts.map +0 -1
- package/dist/cjs/lib/installHelpers.js +0 -65
- package/dist/cjs/lib/loadEnvFiles.d.ts +0 -5
- package/dist/cjs/lib/loadEnvFiles.d.ts.map +0 -1
- package/dist/cjs/lib/loadEnvFiles.js +0 -99
- package/dist/cjs/lib/paths.d.ts +0 -6
- package/dist/cjs/lib/paths.d.ts.map +0 -1
- package/dist/cjs/lib/paths.js +0 -42
- package/dist/cjs/lib/project.d.ts +0 -44
- package/dist/cjs/lib/project.d.ts.map +0 -1
- package/dist/cjs/lib/project.js +0 -268
- package/dist/cjs/lib/version.d.ts +0 -17
- package/dist/cjs/lib/version.d.ts.map +0 -1
- package/dist/cjs/lib/version.js +0 -107
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/packageManager/display.d.ts +0 -90
- package/dist/cjs/packageManager/display.d.ts.map +0 -1
- package/dist/cjs/packageManager/display.js +0 -139
- package/dist/cjs/packageManager/exec.d.ts +0 -77
- package/dist/cjs/packageManager/exec.d.ts.map +0 -1
- package/dist/cjs/packageManager/exec.js +0 -152
- package/dist/cjs/packageManager/index.d.ts +0 -13
- package/dist/cjs/packageManager/index.d.ts.map +0 -1
- package/dist/cjs/packageManager/index.js +0 -73
- package/dist/cjs/packageManager/packages.d.ts +0 -39
- package/dist/cjs/packageManager/packages.d.ts.map +0 -1
- package/dist/cjs/packageManager/packages.js +0 -91
- package/dist/cjs/packageManager/workspaces.d.ts +0 -4
- package/dist/cjs/packageManager/workspaces.d.ts.map +0 -1
- package/dist/cjs/packageManager/workspaces.js +0 -93
- package/dist/cjs/telemetry/index.d.ts +0 -20
- package/dist/cjs/telemetry/index.d.ts.map +0 -1
- package/dist/cjs/telemetry/index.js +0 -64
- package/dist/package.json +0 -1
package/dist/cjs/lib/project.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var project_exports = {};
|
|
30
|
-
__export(project_exports, {
|
|
31
|
-
addEnvVar: () => addEnvVar,
|
|
32
|
-
addEnvVarTask: () => addEnvVarTask,
|
|
33
|
-
getGraphqlPath: () => getGraphqlPath,
|
|
34
|
-
getInstalledRedwoodVersion: () => getInstalledRedwoodVersion,
|
|
35
|
-
graphFunctionDoesExist: () => graphFunctionDoesExist,
|
|
36
|
-
isTypeScriptProject: () => isTypeScriptProject,
|
|
37
|
-
setRedwoodCWD: () => setRedwoodCWD,
|
|
38
|
-
setTomlSetting: () => setTomlSetting,
|
|
39
|
-
updateTomlConfig: () => updateTomlConfig,
|
|
40
|
-
updateTomlConfigTask: () => updateTomlConfigTask
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(project_exports);
|
|
43
|
-
var fs = __toESM(require("node:fs"), 1);
|
|
44
|
-
var path = __toESM(require("node:path"), 1);
|
|
45
|
-
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
46
|
-
var toml = __toESM(require("smol-toml"), 1);
|
|
47
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
48
|
-
var import_colors = require("./colors.js");
|
|
49
|
-
var import_paths = require("./paths.js");
|
|
50
|
-
const getGraphqlPath = () => {
|
|
51
|
-
return (0, import_project_config.resolveFile)(path.join((0, import_paths.getPaths)().api.functions, "graphql"));
|
|
52
|
-
};
|
|
53
|
-
const graphFunctionDoesExist = () => {
|
|
54
|
-
const graphqlPath = getGraphqlPath();
|
|
55
|
-
return graphqlPath && fs.existsSync(graphqlPath);
|
|
56
|
-
};
|
|
57
|
-
const isTypeScriptProject = () => {
|
|
58
|
-
const paths = (0, import_paths.getPaths)();
|
|
59
|
-
return fs.existsSync(path.join(paths.web.base, "tsconfig.json")) || fs.existsSync(path.join(paths.api.base, "tsconfig.json"));
|
|
60
|
-
};
|
|
61
|
-
const getInstalledRedwoodVersion = () => {
|
|
62
|
-
try {
|
|
63
|
-
const packageJson = require("../../package.json");
|
|
64
|
-
return packageJson.version;
|
|
65
|
-
} catch {
|
|
66
|
-
console.error(import_colors.colors.error("Could not find installed Cedar version"));
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const updateTomlConfig = (packageName) => {
|
|
71
|
-
const configTomlPath = (0, import_project_config.getConfigPath)();
|
|
72
|
-
const originalTomlContent = fs.readFileSync(configTomlPath, "utf-8");
|
|
73
|
-
let tomlToAppend = {};
|
|
74
|
-
const config = (0, import_project_config.getConfig)();
|
|
75
|
-
const cliSection = config.experimental?.cli;
|
|
76
|
-
if (!cliSection) {
|
|
77
|
-
tomlToAppend = {
|
|
78
|
-
experimental: {
|
|
79
|
-
cli: {
|
|
80
|
-
autoInstall: true,
|
|
81
|
-
plugins: [{ package: packageName, enabled: true }]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
} else if (cliSection.plugins) {
|
|
86
|
-
const packageExists = cliSection.plugins.some(
|
|
87
|
-
(plugin) => plugin.package === packageName
|
|
88
|
-
);
|
|
89
|
-
if (!packageExists) {
|
|
90
|
-
tomlToAppend = {
|
|
91
|
-
experimental: {
|
|
92
|
-
cli: {
|
|
93
|
-
plugins: [{ package: packageName, enabled: true }]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
tomlToAppend = {
|
|
100
|
-
experimental: {
|
|
101
|
-
cli: {
|
|
102
|
-
plugins: [{ package: packageName, enabled: true }]
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const newConfig = originalTomlContent + "\n" + (Object.keys(tomlToAppend).length > 0 ? toml.stringify(tomlToAppend) + "\n" : "");
|
|
108
|
-
return fs.writeFileSync(configTomlPath, newConfig, "utf-8");
|
|
109
|
-
};
|
|
110
|
-
const updateTomlConfigTask = (packageName) => {
|
|
111
|
-
return {
|
|
112
|
-
title: `Updating config file to configure ${packageName} ...`,
|
|
113
|
-
task: () => {
|
|
114
|
-
updateTomlConfig(packageName);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
const addEnvVarTask = (name, value, comment) => {
|
|
119
|
-
return {
|
|
120
|
-
title: `Adding ${name} var to .env...`,
|
|
121
|
-
task: () => {
|
|
122
|
-
addEnvVar(name, value, comment);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
const addEnvVar = (name, value, comment) => {
|
|
127
|
-
const envPath = path.join((0, import_paths.getPaths)().base, ".env");
|
|
128
|
-
let envFile = "";
|
|
129
|
-
const newEnvironmentVariable = [
|
|
130
|
-
comment && `# ${comment}`,
|
|
131
|
-
`${name}=${value}`,
|
|
132
|
-
""
|
|
133
|
-
].flat().join("\n");
|
|
134
|
-
if (fs.existsSync(envPath)) {
|
|
135
|
-
envFile = fs.readFileSync(envPath).toString();
|
|
136
|
-
const existingEnvVars = import_dotenv.default.parse(envFile);
|
|
137
|
-
if (existingEnvVars[name] && existingEnvVars[name] === value) {
|
|
138
|
-
return envFile;
|
|
139
|
-
}
|
|
140
|
-
if (existingEnvVars[name]) {
|
|
141
|
-
const p = [
|
|
142
|
-
`# Note: The existing environment variable ${name} was not overwritten. Uncomment to use its new value.`,
|
|
143
|
-
comment && `# ${comment}`,
|
|
144
|
-
`# ${name}=${value}`,
|
|
145
|
-
""
|
|
146
|
-
].flat().join("\n");
|
|
147
|
-
envFile += "\n" + p;
|
|
148
|
-
} else {
|
|
149
|
-
envFile += "\n" + newEnvironmentVariable;
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
envFile = newEnvironmentVariable;
|
|
153
|
-
}
|
|
154
|
-
return fs.writeFileSync(envPath, envFile);
|
|
155
|
-
};
|
|
156
|
-
function setRedwoodCWD(cwd) {
|
|
157
|
-
const configFiles = ["cedar.toml", "redwood.toml"];
|
|
158
|
-
cwd ??= process.env.CEDAR_CWD;
|
|
159
|
-
cwd ??= process.env.RWJS_CWD;
|
|
160
|
-
if (cwd) {
|
|
161
|
-
const absCwd = path.resolve(process.cwd(), cwd);
|
|
162
|
-
const found = configFiles.some((f) => fs.existsSync(path.join(absCwd, f)));
|
|
163
|
-
if (!found) {
|
|
164
|
-
const tomls = configFiles.join('" or "');
|
|
165
|
-
throw new Error(`Couldn't find a "${tomls}" file in ${absCwd}`);
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
const configTomlPath = (0, import_project_config.findUp)("cedar.toml", process.cwd()) || (0, import_project_config.findUp)("redwood.toml", process.cwd());
|
|
169
|
-
if (!configTomlPath) {
|
|
170
|
-
throw new Error(
|
|
171
|
-
`Couldn't find up a "cedar.toml" or "redwood.toml" file from ${process.cwd()}`
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
cwd = path.dirname(configTomlPath);
|
|
175
|
-
}
|
|
176
|
-
process.env.CEDAR_CWD = cwd;
|
|
177
|
-
}
|
|
178
|
-
function setTomlSetting(section, setting, value) {
|
|
179
|
-
const cedarTomlPath = (0, import_project_config.getConfigPath)();
|
|
180
|
-
const originalTomlContent = fs.readFileSync(cedarTomlPath, "utf-8");
|
|
181
|
-
const cedarTomlObject = toml.parse(originalTomlContent);
|
|
182
|
-
const sectionValue = cedarTomlObject[section];
|
|
183
|
-
const existingValue = (
|
|
184
|
-
// I don't like this type cast, but I couldn't come up with a much better
|
|
185
|
-
// solution
|
|
186
|
-
sectionValue?.[setting]
|
|
187
|
-
);
|
|
188
|
-
if (existingValue === value) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
let newTomlContent = originalTomlContent.replace(/\n$/, "") + `
|
|
192
|
-
|
|
193
|
-
[${section}]
|
|
194
|
-
${setting} = ${value}`;
|
|
195
|
-
const hasExistingSettingSection = !!cedarTomlObject?.[section];
|
|
196
|
-
if (hasExistingSettingSection) {
|
|
197
|
-
const existingSectionSettings = Object.keys(cedarTomlObject[section]);
|
|
198
|
-
let inSection = false;
|
|
199
|
-
let indentation = "";
|
|
200
|
-
let insertionIndex = 1;
|
|
201
|
-
let updateExistingValue = false;
|
|
202
|
-
let updateExistingCommentedValue = false;
|
|
203
|
-
const tomlLines = originalTomlContent.split("\n");
|
|
204
|
-
tomlLines.forEach((line, index) => {
|
|
205
|
-
if (line.startsWith(`[${section}]`)) {
|
|
206
|
-
inSection = true;
|
|
207
|
-
insertionIndex = index + 1;
|
|
208
|
-
} else {
|
|
209
|
-
if (/^\s*\[/.test(line)) {
|
|
210
|
-
inSection = false;
|
|
211
|
-
}
|
|
212
|
-
if (inSection && !updateExistingValue) {
|
|
213
|
-
for (const existingSectionSetting of existingSectionSettings) {
|
|
214
|
-
const matches = line.match(
|
|
215
|
-
new RegExp(`^(\\s*)${existingSectionSetting}\\s*=`, "i")
|
|
216
|
-
);
|
|
217
|
-
if (!updateExistingValue && matches) {
|
|
218
|
-
if (!updateExistingCommentedValue) {
|
|
219
|
-
indentation = matches[1];
|
|
220
|
-
}
|
|
221
|
-
if (existingSectionSetting === setting) {
|
|
222
|
-
updateExistingValue = true;
|
|
223
|
-
insertionIndex = index;
|
|
224
|
-
indentation = matches[1];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (!updateExistingValue && !updateExistingCommentedValue && /^\s*\w+\s*=/.test(line)) {
|
|
228
|
-
insertionIndex = index + 1;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (!updateExistingValue) {
|
|
232
|
-
const matchesComment = line.match(
|
|
233
|
-
new RegExp(`^(\\s*)#(\\s*)${setting}\\s*=`, "i")
|
|
234
|
-
);
|
|
235
|
-
if (matchesComment) {
|
|
236
|
-
const commentIndentation = matchesComment[1].length > matchesComment[2].length ? matchesComment[1] : matchesComment[2];
|
|
237
|
-
if (commentIndentation.length - 1 > indentation.length) {
|
|
238
|
-
indentation = commentIndentation;
|
|
239
|
-
}
|
|
240
|
-
updateExistingCommentedValue = true;
|
|
241
|
-
insertionIndex = index;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
tomlLines.splice(
|
|
248
|
-
insertionIndex,
|
|
249
|
-
updateExistingValue || updateExistingCommentedValue ? 1 : 0,
|
|
250
|
-
`${indentation}${setting} = ${value}`
|
|
251
|
-
);
|
|
252
|
-
newTomlContent = tomlLines.join("\n");
|
|
253
|
-
}
|
|
254
|
-
fs.writeFileSync(cedarTomlPath, newTomlContent);
|
|
255
|
-
}
|
|
256
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
257
|
-
0 && (module.exports = {
|
|
258
|
-
addEnvVar,
|
|
259
|
-
addEnvVarTask,
|
|
260
|
-
getGraphqlPath,
|
|
261
|
-
getInstalledRedwoodVersion,
|
|
262
|
-
graphFunctionDoesExist,
|
|
263
|
-
isTypeScriptProject,
|
|
264
|
-
setRedwoodCWD,
|
|
265
|
-
setTomlSetting,
|
|
266
|
-
updateTomlConfig,
|
|
267
|
-
updateTomlConfigTask
|
|
268
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if the package at the given version is compatible with the current version of the user's RedwoodJS project. This is
|
|
3
|
-
* determined by checking if the package's engines.redwoodjs field intersects with the user's RedwoodJS version.
|
|
4
|
-
*
|
|
5
|
-
* If the preferred version is not compatible, the latest compatible version will be returned if one exists.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getCompatibilityData(packageName: string, preferredVersionOrTag: string): Promise<{
|
|
8
|
-
preferred: {
|
|
9
|
-
tag: string | undefined;
|
|
10
|
-
version: string;
|
|
11
|
-
};
|
|
12
|
-
compatible: {
|
|
13
|
-
tag: string | undefined;
|
|
14
|
-
version: string;
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
17
|
-
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/version.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM;;;;;;;;;GA2F9B"}
|
package/dist/cjs/lib/version.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var version_exports = {};
|
|
30
|
-
__export(version_exports, {
|
|
31
|
-
getCompatibilityData: () => getCompatibilityData
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(version_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_path = __toESM(require("path"), 1);
|
|
36
|
-
var import_semver = __toESM(require("semver"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function getCorrespondingTag(version, distTags) {
|
|
39
|
-
return Object.entries(distTags).find(([_, v]) => v === version)?.[0];
|
|
40
|
-
}
|
|
41
|
-
async function getCompatibilityData(packageName, preferredVersionOrTag) {
|
|
42
|
-
const projectPackageJson = JSON.parse(
|
|
43
|
-
import_node_fs.default.readFileSync(import_path.default.join((0, import_project_config.getPaths)().base, "package.json"), {
|
|
44
|
-
encoding: "utf8"
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
const projectRedwoodVersion = projectPackageJson.devDependencies["@cedarjs/core"];
|
|
48
|
-
const semverVersion = import_semver.default.parse(preferredVersionOrTag);
|
|
49
|
-
const isUsingTag = semverVersion === null;
|
|
50
|
-
const res = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
51
|
-
const packument = await res.json();
|
|
52
|
-
if (packument.error !== void 0) {
|
|
53
|
-
throw new Error(packument.error);
|
|
54
|
-
}
|
|
55
|
-
if (isUsingTag) {
|
|
56
|
-
if (packument["dist-tags"][preferredVersionOrTag] === void 0) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
`The package '${packageName}' does not have a tag '${preferredVersionOrTag}'`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
if (packument.versions[preferredVersionOrTag] === void 0) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`The package '${packageName}' does not have a version '${preferredVersionOrTag}'`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const preferredVersion = isUsingTag ? packument["dist-tags"][preferredVersionOrTag] : preferredVersionOrTag;
|
|
69
|
-
const packageRedwoodSpecification = packument.versions[preferredVersion].engines?.redwoodjs;
|
|
70
|
-
if (packageRedwoodSpecification !== void 0 && import_semver.default.intersects(projectRedwoodVersion, packageRedwoodSpecification)) {
|
|
71
|
-
const tag = getCorrespondingTag(preferredVersion, packument["dist-tags"]);
|
|
72
|
-
return {
|
|
73
|
-
preferred: {
|
|
74
|
-
tag,
|
|
75
|
-
version: preferredVersion
|
|
76
|
-
},
|
|
77
|
-
compatible: {
|
|
78
|
-
tag,
|
|
79
|
-
version: preferredVersion
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const versions = import_semver.default.sort(Object.keys(packument.versions));
|
|
84
|
-
for (let i = versions.length - 1; i >= 0; i--) {
|
|
85
|
-
const redwoodVersionRequired = packument.versions[versions[i]].engines?.redwoodjs;
|
|
86
|
-
if (redwoodVersionRequired === void 0) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (import_semver.default.intersects(projectRedwoodVersion, redwoodVersionRequired)) {
|
|
90
|
-
return {
|
|
91
|
-
preferred: {
|
|
92
|
-
tag: getCorrespondingTag(preferredVersion, packument["dist-tags"]),
|
|
93
|
-
version: preferredVersion
|
|
94
|
-
},
|
|
95
|
-
compatible: {
|
|
96
|
-
tag: getCorrespondingTag(versions[i], packument["dist-tags"]),
|
|
97
|
-
version: versions[i]
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
throw new Error(`No compatible version of '${packageName}' was found`);
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
getCompatibilityData
|
|
107
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the formatted install command for the detected package manager.
|
|
3
|
-
*
|
|
4
|
-
* yarn → `yarn install`
|
|
5
|
-
* npm → `npm install`
|
|
6
|
-
* pnpm → `pnpm install`
|
|
7
|
-
*/
|
|
8
|
-
export declare function formatInstallCommand(): string;
|
|
9
|
-
/**
|
|
10
|
-
* Returns a formatted string for running a Cedar CLI command via the detected
|
|
11
|
-
* package manager.
|
|
12
|
-
*
|
|
13
|
-
* npm → `npx cedar <args>`
|
|
14
|
-
* yarn → `yarn cedar <args>`
|
|
15
|
-
* pnpm → `pnpm cedar <args>`
|
|
16
|
-
*/
|
|
17
|
-
export declare function formatCedarCommand(args: string[]): string;
|
|
18
|
-
/**
|
|
19
|
-
* Returns a formatted string for running a package.json script via the
|
|
20
|
-
* detected package manager.
|
|
21
|
-
*
|
|
22
|
-
* npm → `npm run <script>[ -- args]`
|
|
23
|
-
* yarn → `yarn <script> [args]`
|
|
24
|
-
* pnpm → `pnpm <script> [args]`
|
|
25
|
-
*/
|
|
26
|
-
export declare function formatRunScriptCommand(script: string, args?: string[]): string;
|
|
27
|
-
/**
|
|
28
|
-
* Returns a formatted string for running a package.json script in a workspace
|
|
29
|
-
* via the detected package manager.
|
|
30
|
-
*
|
|
31
|
-
* yarn → `yarn workspace <workspace> <script> [args]`
|
|
32
|
-
* npm → `npm run <script> -w <workspace>[ -- args]`
|
|
33
|
-
* pnpm → `pnpm <script> --filter <workspace>[-- args]`
|
|
34
|
-
*/
|
|
35
|
-
export declare function formatRunWorkspaceScriptCommand(workspace: string, script: string, args?: string[]): string;
|
|
36
|
-
/**
|
|
37
|
-
* Returns a formatted string for running a local binary (from
|
|
38
|
-
* node_modules/.bin) via the detected package manager.
|
|
39
|
-
*
|
|
40
|
-
* yarn → `yarn <bin> [args]` (PnP-safe)
|
|
41
|
-
* npm → `npx <bin> [args]`
|
|
42
|
-
* pnpm → `pnpm exec <bin> [args]`
|
|
43
|
-
*/
|
|
44
|
-
export declare function formatRunBinCommand(bin: string, args?: string[]): string;
|
|
45
|
-
/**
|
|
46
|
-
* Returns a formatted string for running a local binary in a workspace context
|
|
47
|
-
* via the detected package manager.
|
|
48
|
-
*
|
|
49
|
-
* yarn → `yarn workspace <workspace> <bin> [args]`
|
|
50
|
-
* npm → `npm exec -w <workspace> -- <bin> [args]`
|
|
51
|
-
* pnpm → `pnpm exec --filter <workspace> <bin> [args]`
|
|
52
|
-
*/
|
|
53
|
-
export declare function formatRunWorkspaceBinCommand(workspace: string, bin: string, args?: string[]): string;
|
|
54
|
-
/**
|
|
55
|
-
* Returns a formatted string for a one-off package execution via the detected
|
|
56
|
-
* package manager.
|
|
57
|
-
*
|
|
58
|
-
* yarn → `yarn dlx <command> [args]`
|
|
59
|
-
* npm → `npx <command> [args]`
|
|
60
|
-
* pnpm → `pnpm dlx <command> [args]`
|
|
61
|
-
*/
|
|
62
|
-
export declare function formatDlxCommand(command: string, args?: string[]): string;
|
|
63
|
-
/**
|
|
64
|
-
* Returns a formatted string for adding packages to the project root via the
|
|
65
|
-
* detected package manager.
|
|
66
|
-
*
|
|
67
|
-
* yarn → `yarn add [-D] <packages>`
|
|
68
|
-
* npm → `npm install [-D] <packages>`
|
|
69
|
-
* pnpm → `pnpm add [-D] <packages>`
|
|
70
|
-
*/
|
|
71
|
-
export declare function formatAddRootPackagesCommand(packages: string[], dev?: boolean): string;
|
|
72
|
-
/**
|
|
73
|
-
* Returns a formatted string for adding packages to a workspace via the
|
|
74
|
-
* detected package manager.
|
|
75
|
-
*
|
|
76
|
-
* yarn → `yarn workspace <workspace> add [-D] <packages>`
|
|
77
|
-
* npm → `npm install [-D] <packages> -w <workspace>`
|
|
78
|
-
* pnpm → `pnpm add [-D] <packages> --filter <workspace>`
|
|
79
|
-
*/
|
|
80
|
-
export declare function formatAddWorkspacePackagesCommand(workspace: string, packages: string[], dev?: boolean): string;
|
|
81
|
-
/**
|
|
82
|
-
* Returns a formatted string for removing packages from a workspace via the
|
|
83
|
-
* detected package manager.
|
|
84
|
-
*
|
|
85
|
-
* yarn → `yarn workspace <workspace> remove <packages>`
|
|
86
|
-
* npm → `npm uninstall <packages> -w <workspace>`
|
|
87
|
-
* pnpm → `pnpm remove <packages> --filter <workspace>`
|
|
88
|
-
*/
|
|
89
|
-
export declare function formatRemoveWorkspacePackagesCommand(workspace: string, packages: string[]): string;
|
|
90
|
-
//# sourceMappingURL=display.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/packageManager/display.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CASzD;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAgBR;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,CAa5E;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAcR;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,CAS7E;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAAE,EAClB,GAAG,UAAQ,GACV,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,GAAG,UAAQ,GACV,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAcR"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var display_exports = {};
|
|
20
|
-
__export(display_exports, {
|
|
21
|
-
formatAddRootPackagesCommand: () => formatAddRootPackagesCommand,
|
|
22
|
-
formatAddWorkspacePackagesCommand: () => formatAddWorkspacePackagesCommand,
|
|
23
|
-
formatCedarCommand: () => formatCedarCommand,
|
|
24
|
-
formatDlxCommand: () => formatDlxCommand,
|
|
25
|
-
formatInstallCommand: () => formatInstallCommand,
|
|
26
|
-
formatRemoveWorkspacePackagesCommand: () => formatRemoveWorkspacePackagesCommand,
|
|
27
|
-
formatRunBinCommand: () => formatRunBinCommand,
|
|
28
|
-
formatRunScriptCommand: () => formatRunScriptCommand,
|
|
29
|
-
formatRunWorkspaceBinCommand: () => formatRunWorkspaceBinCommand,
|
|
30
|
-
formatRunWorkspaceScriptCommand: () => formatRunWorkspaceScriptCommand
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(display_exports);
|
|
33
|
-
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
34
|
-
function formatInstallCommand() {
|
|
35
|
-
return `${(0, import_packageManager.getPackageManager)()} install`;
|
|
36
|
-
}
|
|
37
|
-
function formatCedarCommand(args) {
|
|
38
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
39
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
40
|
-
if (pm === "npm") {
|
|
41
|
-
return `npx cedar${argStr}`;
|
|
42
|
-
}
|
|
43
|
-
return `${pm} cedar${argStr}`;
|
|
44
|
-
}
|
|
45
|
-
function formatRunScriptCommand(script, args = []) {
|
|
46
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
47
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
48
|
-
if (pm === "npm") {
|
|
49
|
-
const separator = args.length > 0 ? " -- " : "";
|
|
50
|
-
return `npm run ${script}${separator}${args.join(" ")}`;
|
|
51
|
-
}
|
|
52
|
-
return `${pm} ${script}${argStr}`;
|
|
53
|
-
}
|
|
54
|
-
function formatRunWorkspaceScriptCommand(workspace, script, args = []) {
|
|
55
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
56
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
57
|
-
if (pm === "yarn") {
|
|
58
|
-
return `yarn workspace ${workspace} ${script}${argStr}`;
|
|
59
|
-
}
|
|
60
|
-
if (pm === "npm") {
|
|
61
|
-
const separator2 = args.length > 0 ? " -- " : "";
|
|
62
|
-
return `npm run ${script} -w ${workspace}${separator2}${args.join(" ")}`;
|
|
63
|
-
}
|
|
64
|
-
const separator = args.length > 0 ? " -- " : "";
|
|
65
|
-
return `pnpm ${script} --filter ${workspace}${separator}${args.join(" ")}`;
|
|
66
|
-
}
|
|
67
|
-
function formatRunBinCommand(bin, args = []) {
|
|
68
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
69
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
70
|
-
if (pm === "npm") {
|
|
71
|
-
return `npx ${bin}${argStr}`;
|
|
72
|
-
}
|
|
73
|
-
if (pm === "pnpm") {
|
|
74
|
-
return `pnpm exec ${bin}${argStr}`;
|
|
75
|
-
}
|
|
76
|
-
return `yarn ${bin}${argStr}`;
|
|
77
|
-
}
|
|
78
|
-
function formatRunWorkspaceBinCommand(workspace, bin, args = []) {
|
|
79
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
80
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
81
|
-
if (pm === "yarn") {
|
|
82
|
-
return `yarn workspace ${workspace} ${bin}${argStr}`;
|
|
83
|
-
}
|
|
84
|
-
if (pm === "npm") {
|
|
85
|
-
return `npm exec -w ${workspace} -- ${bin}${argStr}`;
|
|
86
|
-
}
|
|
87
|
-
return `pnpm exec --filter ${workspace} ${bin}${argStr}`;
|
|
88
|
-
}
|
|
89
|
-
function formatDlxCommand(command, args = []) {
|
|
90
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
91
|
-
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
92
|
-
if (pm === "npm") {
|
|
93
|
-
return `npx ${command}${argStr}`;
|
|
94
|
-
}
|
|
95
|
-
return `${pm} dlx ${command}${argStr}`;
|
|
96
|
-
}
|
|
97
|
-
function formatAddRootPackagesCommand(packages, dev = false) {
|
|
98
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
99
|
-
const devFlag = dev ? " -D" : "";
|
|
100
|
-
const pkgStr = packages.join(" ");
|
|
101
|
-
const addCmd = pm === "npm" ? "install" : "add";
|
|
102
|
-
return `${pm} ${addCmd}${devFlag} ${pkgStr}`;
|
|
103
|
-
}
|
|
104
|
-
function formatAddWorkspacePackagesCommand(workspace, packages, dev = false) {
|
|
105
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
106
|
-
const devFlag = dev ? " -D" : "";
|
|
107
|
-
const pkgStr = packages.join(" ");
|
|
108
|
-
if (pm === "yarn") {
|
|
109
|
-
return `yarn workspace ${workspace} add${devFlag} ${pkgStr}`;
|
|
110
|
-
}
|
|
111
|
-
if (pm === "npm") {
|
|
112
|
-
return `npm install${devFlag} ${pkgStr} -w ${workspace}`;
|
|
113
|
-
}
|
|
114
|
-
return `pnpm add${devFlag} ${pkgStr} --filter ${workspace}`;
|
|
115
|
-
}
|
|
116
|
-
function formatRemoveWorkspacePackagesCommand(workspace, packages) {
|
|
117
|
-
const pm = (0, import_packageManager.getPackageManager)();
|
|
118
|
-
const pkgStr = packages.join(" ");
|
|
119
|
-
if (pm === "yarn") {
|
|
120
|
-
return `yarn workspace ${workspace} remove ${pkgStr}`;
|
|
121
|
-
}
|
|
122
|
-
if (pm === "npm") {
|
|
123
|
-
return `npm uninstall ${pkgStr} -w ${workspace}`;
|
|
124
|
-
}
|
|
125
|
-
return `pnpm remove ${pkgStr} --filter ${workspace}`;
|
|
126
|
-
}
|
|
127
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
-
0 && (module.exports = {
|
|
129
|
-
formatAddRootPackagesCommand,
|
|
130
|
-
formatAddWorkspacePackagesCommand,
|
|
131
|
-
formatCedarCommand,
|
|
132
|
-
formatDlxCommand,
|
|
133
|
-
formatInstallCommand,
|
|
134
|
-
formatRemoveWorkspacePackagesCommand,
|
|
135
|
-
formatRunBinCommand,
|
|
136
|
-
formatRunScriptCommand,
|
|
137
|
-
formatRunWorkspaceBinCommand,
|
|
138
|
-
formatRunWorkspaceScriptCommand
|
|
139
|
-
});
|