@cedarjs/cli-helpers 2.2.1-next.0 → 2.2.1-next.21
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/auth/authFiles.js +1 -1
- package/dist/auth/authTasks.js +1 -1
- package/dist/cjs/auth/authFiles.js +5 -5
- package/dist/cjs/auth/authTasks.js +14 -14
- package/dist/cjs/lib/index.js +4 -4
- package/dist/cjs/lib/version.js +2 -2
- package/dist/lib/index.js +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/auth/authFiles.js
CHANGED
package/dist/auth/authTasks.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(authFiles_exports, {
|
|
|
32
32
|
generateUniqueFileNames: () => generateUniqueFileNames
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(authFiles_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
36
36
|
var import_path = __toESM(require("path"), 1);
|
|
37
37
|
var import_pascalcase = __toESM(require("pascalcase"), 1);
|
|
38
38
|
var import_lib = require("../lib/index.js");
|
|
@@ -41,10 +41,10 @@ var import_project = require("../lib/project.js");
|
|
|
41
41
|
const apiSideFiles = async ({ basedir, webAuthn }) => {
|
|
42
42
|
const apiSrcPath = (0, import_paths.getPaths)().api.src;
|
|
43
43
|
const apiBaseTemplatePath = import_path.default.join(basedir, "templates", "api");
|
|
44
|
-
const templateDirectories =
|
|
44
|
+
const templateDirectories = import_node_fs.default.readdirSync(apiBaseTemplatePath);
|
|
45
45
|
let filesRecord = {};
|
|
46
46
|
for (const dir of templateDirectories) {
|
|
47
|
-
const templateFiles =
|
|
47
|
+
const templateFiles = import_node_fs.default.readdirSync(import_path.default.join(apiBaseTemplatePath, dir));
|
|
48
48
|
const filePaths = templateFiles.filter((fileName) => {
|
|
49
49
|
const fileNameParts = fileName.split(".");
|
|
50
50
|
return fileNameParts.length <= 3 || fileNameParts.at(-3) !== "webAuthn";
|
|
@@ -72,7 +72,7 @@ const apiSideFiles = async ({ basedir, webAuthn }) => {
|
|
|
72
72
|
return { templateFilePath, outputFilePath };
|
|
73
73
|
});
|
|
74
74
|
for (const paths of filePaths) {
|
|
75
|
-
const content =
|
|
75
|
+
const content = import_node_fs.default.readFileSync(paths.templateFilePath, "utf8");
|
|
76
76
|
filesRecord = {
|
|
77
77
|
...filesRecord,
|
|
78
78
|
[paths.outputFilePath]: (0, import_project.isTypeScriptProject)() ? content : await (0, import_lib.transformTSToJS)(paths.outputFilePath, content)
|
|
@@ -86,7 +86,7 @@ function generateUniqueFileNames(filesRecord, provider) {
|
|
|
86
86
|
Object.keys(filesRecord).forEach((fullPath) => {
|
|
87
87
|
let newFullPath = fullPath;
|
|
88
88
|
let i = 1;
|
|
89
|
-
while (
|
|
89
|
+
while (import_node_fs.default.existsSync(newFullPath)) {
|
|
90
90
|
const nameParts = import_path.default.basename(fullPath).split(".");
|
|
91
91
|
if (nameParts[0] === provider) {
|
|
92
92
|
const newFileName = provider + (i + 1) + "." + nameParts.slice(1).join(".");
|
|
@@ -40,7 +40,7 @@ __export(authTasks_exports, {
|
|
|
40
40
|
setAuthSetupMode: () => setAuthSetupMode
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(authTasks_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
44
44
|
var import_path = __toESM(require("path"), 1);
|
|
45
45
|
var import_prompt_adapter_enquirer = require("@listr2/prompt-adapter-enquirer");
|
|
46
46
|
var import_project_config = require("@cedarjs/project-config");
|
|
@@ -78,7 +78,7 @@ const addApiConfig = ({
|
|
|
78
78
|
if (!graphqlPath) {
|
|
79
79
|
throw new Error("Could not find your graphql file path");
|
|
80
80
|
}
|
|
81
|
-
const content =
|
|
81
|
+
const content = import_node_fs.default.readFileSync(graphqlPath).toString();
|
|
82
82
|
let newContent = content;
|
|
83
83
|
if (authDecoderImport) {
|
|
84
84
|
if (replaceExistingImport) {
|
|
@@ -107,11 +107,11 @@ $1$2$3`
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
if (newContent !== content) {
|
|
110
|
-
|
|
110
|
+
import_node_fs.default.writeFileSync(graphqlPath, newContent);
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
const apiSrcDoesExist = () => {
|
|
114
|
-
return
|
|
114
|
+
return import_node_fs.default.existsSync(import_path.default.join((0, import_paths.getPaths)().api.src));
|
|
115
115
|
};
|
|
116
116
|
const addAuthImportToApp = (content) => {
|
|
117
117
|
const contentLines = content.split("\n");
|
|
@@ -207,11 +207,11 @@ const addConfigToWebApp = () => {
|
|
|
207
207
|
title: "Updating web/src/App.{jsx,tsx}",
|
|
208
208
|
task: (ctx, task) => {
|
|
209
209
|
const webAppPath = getWebAppPath();
|
|
210
|
-
if (!
|
|
210
|
+
if (!import_node_fs.default.existsSync(webAppPath)) {
|
|
211
211
|
const ext = (0, import_project.isTypeScriptProject)() ? "tsx" : "jsx";
|
|
212
212
|
throw new Error(`Could not find root App.${ext}`);
|
|
213
213
|
}
|
|
214
|
-
let content =
|
|
214
|
+
let content = import_node_fs.default.readFileSync(webAppPath, "utf-8");
|
|
215
215
|
if (!content.includes(AUTH_PROVIDER_HOOK_IMPORT)) {
|
|
216
216
|
content = addAuthImportToApp(content);
|
|
217
217
|
}
|
|
@@ -231,13 +231,13 @@ const addConfigToWebApp = () => {
|
|
|
231
231
|
"Could not find <RedwoodApolloProvider>.\nIf you are using a custom GraphQL Client you will have to make sure it gets access to your `useAuth`, if it needs it."
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
|
-
|
|
234
|
+
import_node_fs.default.writeFileSync(webAppPath, content);
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
};
|
|
238
238
|
const createWebAuth = (basedir, webAuthn) => {
|
|
239
239
|
const templatesBaseDir = import_path.default.join(basedir, "templates", "web");
|
|
240
|
-
const templates =
|
|
240
|
+
const templates = import_node_fs.default.readdirSync(templatesBaseDir);
|
|
241
241
|
const rscEnabled = (0, import_project_config.getConfig)().experimental?.rsc?.enabled;
|
|
242
242
|
const templateStart = "auth" + (webAuthn ? ".webAuthn" : "") + (rscEnabled ? ".rsc" : "") + ".ts";
|
|
243
243
|
const templateFileName = templates.find((template) => {
|
|
@@ -270,12 +270,12 @@ const createWebAuth = (basedir, webAuthn) => {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
authFileName = authFileName + "." + ext;
|
|
273
|
-
let template =
|
|
273
|
+
let template = import_node_fs.default.readFileSync(
|
|
274
274
|
import_path.default.join(templatesBaseDir, templateFileName),
|
|
275
275
|
"utf-8"
|
|
276
276
|
);
|
|
277
277
|
template = isTSProject ? template : await (0, import_lib.transformTSToJS)(authFileName, template);
|
|
278
|
-
|
|
278
|
+
import_node_fs.default.writeFileSync(authFileName, template);
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
};
|
|
@@ -284,14 +284,14 @@ const addConfigToRoutes = () => {
|
|
|
284
284
|
title: "Updating Routes file...",
|
|
285
285
|
task: () => {
|
|
286
286
|
const webRoutesPath = (0, import_paths.getPaths)().web.routes;
|
|
287
|
-
let content =
|
|
287
|
+
let content = import_node_fs.default.readFileSync(webRoutesPath).toString();
|
|
288
288
|
if (!content.includes(AUTH_HOOK_IMPORT)) {
|
|
289
289
|
content = addAuthImportToRoutes(content);
|
|
290
290
|
}
|
|
291
291
|
if (!hasUseAuthHook("Router", content)) {
|
|
292
292
|
content = addUseAuthHook("Router", content);
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
import_node_fs.default.writeFileSync(webRoutesPath, content);
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
};
|
|
@@ -332,7 +332,7 @@ const generateAuthApiFiles = (basedir, webAuthn) => {
|
|
|
332
332
|
};
|
|
333
333
|
};
|
|
334
334
|
function findExistingFiles(filesMap) {
|
|
335
|
-
return Object.keys(filesMap).filter((filePath) =>
|
|
335
|
+
return Object.keys(filesMap).filter((filePath) => import_node_fs.default.existsSync(filePath)).map((filePath) => filePath.replace((0, import_paths.getPaths)().base, ""));
|
|
336
336
|
}
|
|
337
337
|
const addAuthConfigToGqlApi = (authDecoderImport) => ({
|
|
338
338
|
title: "Adding auth config to GraphQL API...",
|
|
@@ -357,7 +357,7 @@ const setAuthSetupMode = (force) => {
|
|
|
357
357
|
ctx.setupMode = "FORCE";
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
const webAppContents =
|
|
360
|
+
const webAppContents = import_node_fs.default.readFileSync(getWebAppPath(), "utf-8");
|
|
361
361
|
if (hasAuthProvider(webAppContents) && ctx.setupMode === "UNKNOWN") {
|
|
362
362
|
const setupMode = "REPLACE";
|
|
363
363
|
ctx.setupMode = setupMode;
|
package/dist/cjs/lib/index.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(lib_exports, {
|
|
|
35
35
|
writeFilesTask: () => writeFilesTask
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(lib_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
39
39
|
var import_path = __toESM(require("path"), 1);
|
|
40
40
|
var babel = __toESM(require("@babel/core"), 1);
|
|
41
41
|
var import_listr2 = require("listr2");
|
|
@@ -105,7 +105,7 @@ const prettify = async (templateFilename, renderedTemplate) => {
|
|
|
105
105
|
const writeFile = (target, contents, { existingFiles = "FAIL" } = {}, task = {}) => {
|
|
106
106
|
const { base } = (0, import_paths.getPaths)();
|
|
107
107
|
task.title = `Writing \`./${import_path.default.relative(base, target)}\``;
|
|
108
|
-
const exists =
|
|
108
|
+
const exists = import_node_fs.default.existsSync(target);
|
|
109
109
|
if (exists && existingFiles === "FAIL") {
|
|
110
110
|
throw new Error(`${target} already exists.`);
|
|
111
111
|
}
|
|
@@ -115,8 +115,8 @@ const writeFile = (target, contents, { existingFiles = "FAIL" } = {}, task = {})
|
|
|
115
115
|
}
|
|
116
116
|
const filename = import_path.default.basename(target);
|
|
117
117
|
const targetDir = target.replace(filename, "");
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
import_node_fs.default.mkdirSync(targetDir, { recursive: true });
|
|
119
|
+
import_node_fs.default.writeFileSync(target, contents);
|
|
120
120
|
task.title = `Successfully wrote file \`./${import_path.default.relative(base, target)}\``;
|
|
121
121
|
};
|
|
122
122
|
const writeFilesTask = (files, options) => {
|
package/dist/cjs/lib/version.js
CHANGED
|
@@ -31,7 +31,7 @@ __export(version_exports, {
|
|
|
31
31
|
getCompatibilityData: () => getCompatibilityData
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(version_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
35
|
var import_path = __toESM(require("path"), 1);
|
|
36
36
|
var import_semver = __toESM(require("semver"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
@@ -40,7 +40,7 @@ function getCorrespondingTag(version, distTags) {
|
|
|
40
40
|
}
|
|
41
41
|
async function getCompatibilityData(packageName, preferredVersionOrTag) {
|
|
42
42
|
const projectPackageJson = JSON.parse(
|
|
43
|
-
|
|
43
|
+
import_node_fs.default.readFileSync(import_path.default.join((0, import_project_config.getPaths)().base, "package.json"), {
|
|
44
44
|
encoding: "utf8"
|
|
45
45
|
})
|
|
46
46
|
);
|
package/dist/lib/index.js
CHANGED
package/dist/lib/version.js
CHANGED