@cedarjs/cli-helpers 0.0.4
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/auth/authFiles.d.ts +44 -0
- package/dist/auth/authFiles.d.ts.map +1 -0
- package/dist/auth/authFiles.js +74 -0
- package/dist/auth/authTasks.d.ts +49 -0
- package/dist/auth/authTasks.d.ts.map +1 -0
- package/dist/auth/authTasks.js +345 -0
- package/dist/auth/setupHelpers.d.ts +26 -0
- package/dist/auth/setupHelpers.d.ts.map +1 -0
- package/dist/auth/setupHelpers.js +127 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/cjs/auth/authFiles.d.ts +44 -0
- package/dist/cjs/auth/authFiles.d.ts.map +1 -0
- package/dist/cjs/auth/authFiles.js +109 -0
- package/dist/cjs/auth/authTasks.d.ts +49 -0
- package/dist/cjs/auth/authTasks.d.ts.map +1 -0
- package/dist/cjs/auth/authTasks.js +384 -0
- package/dist/cjs/auth/setupHelpers.d.ts +26 -0
- package/dist/cjs/auth/setupHelpers.d.ts.map +1 -0
- package/dist/cjs/auth/setupHelpers.js +151 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/lib/colors.d.ts +23 -0
- package/dist/cjs/lib/colors.d.ts.map +1 -0
- package/dist/cjs/lib/colors.js +52 -0
- package/dist/cjs/lib/index.d.ts +21 -0
- package/dist/cjs/lib/index.d.ts.map +1 -0
- package/dist/cjs/lib/index.js +140 -0
- package/dist/cjs/lib/installHelpers.d.ts +17 -0
- package/dist/cjs/lib/installHelpers.d.ts.map +1 -0
- package/dist/cjs/lib/installHelpers.js +72 -0
- package/dist/cjs/lib/loadEnvFiles.d.ts +5 -0
- package/dist/cjs/lib/loadEnvFiles.d.ts.map +1 -0
- package/dist/cjs/lib/loadEnvFiles.js +101 -0
- package/dist/cjs/lib/paths.d.ts +6 -0
- package/dist/cjs/lib/paths.d.ts.map +1 -0
- package/dist/cjs/lib/paths.js +42 -0
- package/dist/cjs/lib/project.d.ts +42 -0
- package/dist/cjs/lib/project.d.ts.map +1 -0
- package/dist/cjs/lib/project.js +265 -0
- package/dist/cjs/lib/version.d.ts +17 -0
- package/dist/cjs/lib/version.d.ts.map +1 -0
- package/dist/cjs/lib/version.js +107 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/telemetry/index.d.ts +20 -0
- package/dist/cjs/telemetry/index.d.ts.map +1 -0
- package/dist/cjs/telemetry/index.js +62 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/lib/colors.d.ts +23 -0
- package/dist/lib/colors.d.ts.map +1 -0
- package/dist/lib/colors.js +18 -0
- package/dist/lib/index.d.ts +21 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +102 -0
- package/dist/lib/installHelpers.d.ts +17 -0
- package/dist/lib/installHelpers.d.ts.map +1 -0
- package/dist/lib/installHelpers.js +35 -0
- package/dist/lib/loadEnvFiles.d.ts +5 -0
- package/dist/lib/loadEnvFiles.d.ts.map +1 -0
- package/dist/lib/loadEnvFiles.js +64 -0
- package/dist/lib/paths.d.ts +6 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +18 -0
- package/dist/lib/project.d.ts +42 -0
- package/dist/lib/project.d.ts.map +1 -0
- package/dist/lib/project.js +227 -0
- package/dist/lib/version.d.ts +17 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +73 -0
- package/dist/package.json +1 -0
- package/dist/src/auth/__tests__/authFiles.test.d.ts +2 -0
- package/dist/src/auth/__tests__/authFiles.test.d.ts.map +1 -0
- package/dist/src/auth/__tests__/authTasks.test.d.ts +2 -0
- package/dist/src/auth/__tests__/authTasks.test.d.ts.map +1 -0
- package/dist/src/auth/__tests__/mockFsFiles.d.ts +14 -0
- package/dist/src/auth/__tests__/mockFsFiles.d.ts.map +1 -0
- package/dist/src/auth/__tests__/setupHelpers.test.d.ts +2 -0
- package/dist/src/auth/__tests__/setupHelpers.test.d.ts.map +1 -0
- package/dist/src/auth/authFiles.d.ts +44 -0
- package/dist/src/auth/authFiles.d.ts.map +1 -0
- package/dist/src/auth/authTasks.d.ts +49 -0
- package/dist/src/auth/authTasks.d.ts.map +1 -0
- package/dist/src/auth/setupHelpers.d.ts +26 -0
- package/dist/src/auth/setupHelpers.d.ts.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/__tests__/index.test.d.ts +2 -0
- package/dist/src/lib/__tests__/index.test.d.ts.map +1 -0
- package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts +2 -0
- package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts.map +1 -0
- package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts +2 -0
- package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts.map +1 -0
- package/dist/src/lib/__tests__/project.test.d.ts +2 -0
- package/dist/src/lib/__tests__/project.test.d.ts.map +1 -0
- package/dist/src/lib/__tests__/version.test.d.ts +2 -0
- package/dist/src/lib/__tests__/version.test.d.ts.map +1 -0
- package/dist/src/lib/colors.d.ts +23 -0
- package/dist/src/lib/colors.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +21 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/installHelpers.d.ts +17 -0
- package/dist/src/lib/installHelpers.d.ts.map +1 -0
- package/dist/src/lib/loadEnvFiles.d.ts +5 -0
- package/dist/src/lib/loadEnvFiles.d.ts.map +1 -0
- package/dist/src/lib/paths.d.ts +6 -0
- package/dist/src/lib/paths.d.ts.map +1 -0
- package/dist/src/lib/project.d.ts +42 -0
- package/dist/src/lib/project.d.ts.map +1 -0
- package/dist/src/lib/version.d.ts +17 -0
- package/dist/src/lib/version.d.ts.map +1 -0
- package/dist/src/telemetry/index.d.ts +20 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +20 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vitest.config.d.mts +3 -0
- package/dist/vitest.config.d.mts.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Listr } from "listr2";
|
|
2
|
+
import terminalLink from "terminal-link";
|
|
3
|
+
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
4
|
+
import { colors } from "../lib/colors.js";
|
|
5
|
+
import {
|
|
6
|
+
addApiPackages,
|
|
7
|
+
addWebPackages,
|
|
8
|
+
installPackages
|
|
9
|
+
} from "../lib/installHelpers.js";
|
|
10
|
+
import {
|
|
11
|
+
addAuthConfigToGqlApi,
|
|
12
|
+
addConfigToRoutes,
|
|
13
|
+
addConfigToWebApp,
|
|
14
|
+
setAuthSetupMode,
|
|
15
|
+
createWebAuth,
|
|
16
|
+
generateAuthApiFiles
|
|
17
|
+
} from "./authTasks.js";
|
|
18
|
+
const standardAuthBuilder = (yargs) => {
|
|
19
|
+
return yargs.option("force", {
|
|
20
|
+
alias: "f",
|
|
21
|
+
default: false,
|
|
22
|
+
description: "Overwrite existing auth configuration",
|
|
23
|
+
type: "boolean"
|
|
24
|
+
}).option("verbose", {
|
|
25
|
+
alias: "v",
|
|
26
|
+
default: false,
|
|
27
|
+
description: "Log setup output",
|
|
28
|
+
type: "boolean"
|
|
29
|
+
}).epilogue(
|
|
30
|
+
`Also see the ${terminalLink(
|
|
31
|
+
"Redwood CLI Reference",
|
|
32
|
+
"https://redwoodjs.com/docs/cli-commands#setup-auth"
|
|
33
|
+
)}`
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
function truthy(value) {
|
|
37
|
+
return !!value;
|
|
38
|
+
}
|
|
39
|
+
const standardAuthHandler = async ({
|
|
40
|
+
basedir,
|
|
41
|
+
forceArg,
|
|
42
|
+
provider,
|
|
43
|
+
authDecoderImport,
|
|
44
|
+
webAuthn = false,
|
|
45
|
+
webPackages = [],
|
|
46
|
+
apiPackages = [],
|
|
47
|
+
extraTasks,
|
|
48
|
+
notes,
|
|
49
|
+
verbose
|
|
50
|
+
}) => {
|
|
51
|
+
const tasks = new Listr(
|
|
52
|
+
[
|
|
53
|
+
setAuthSetupMode(forceArg),
|
|
54
|
+
generateAuthApiFiles(basedir, webAuthn),
|
|
55
|
+
addConfigToWebApp(),
|
|
56
|
+
createWebAuth(basedir, webAuthn),
|
|
57
|
+
addConfigToRoutes(),
|
|
58
|
+
addAuthConfigToGqlApi(authDecoderImport),
|
|
59
|
+
webPackages.length && addWebPackages(webPackages),
|
|
60
|
+
apiPackages.length && addApiPackages(apiPackages),
|
|
61
|
+
(webPackages.length || apiPackages.length) && installPackages,
|
|
62
|
+
...(extraTasks || []).filter(truthy),
|
|
63
|
+
notes && {
|
|
64
|
+
title: "One more thing...",
|
|
65
|
+
task: (ctx) => {
|
|
66
|
+
if (ctx.setupMode === "REPLACE") {
|
|
67
|
+
notes.push(
|
|
68
|
+
...[
|
|
69
|
+
"",
|
|
70
|
+
`${colors.warning(
|
|
71
|
+
"Your existing auth provider has been replaced!"
|
|
72
|
+
)}`,
|
|
73
|
+
"You'll still need to manually remove your old auth provider's config,",
|
|
74
|
+
"functions, and dependencies (in your web and api package.json's)."
|
|
75
|
+
]
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (ctx.setupMode === "COMBINE") {
|
|
79
|
+
notes.push(
|
|
80
|
+
colors.warning(
|
|
81
|
+
`To avoid overwriting existing files we've generated new file names for the newly generated files. This probably means ${ctx.provider} auth doesn't work out of the box. You'll most likely have to manually merge some of the generated files with your existing auth files`
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
].filter(truthy),
|
|
88
|
+
{
|
|
89
|
+
rendererOptions: { collapseSubtasks: false },
|
|
90
|
+
renderer: verbose ? "verbose" : "default",
|
|
91
|
+
ctx: {
|
|
92
|
+
setupMode: "UNKNOWN",
|
|
93
|
+
provider,
|
|
94
|
+
// provider name passed from CLI
|
|
95
|
+
force: forceArg
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
try {
|
|
100
|
+
await tasks.run();
|
|
101
|
+
if (notes) {
|
|
102
|
+
console.log(`
|
|
103
|
+
${notes.join("\n ")}
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
106
|
+
} catch (e) {
|
|
107
|
+
if (isErrorWithMessage(e)) {
|
|
108
|
+
errorTelemetry(process.argv, e.message);
|
|
109
|
+
console.error(colors.error(e.message));
|
|
110
|
+
}
|
|
111
|
+
if (isErrorWithErrorCode(e)) {
|
|
112
|
+
process.exit(e.exitCode || 1);
|
|
113
|
+
} else {
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function isErrorWithMessage(e) {
|
|
119
|
+
return !!e.message;
|
|
120
|
+
}
|
|
121
|
+
function isErrorWithErrorCode(e) {
|
|
122
|
+
return !isNaN(e.exitCode);
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
standardAuthBuilder,
|
|
126
|
+
standardAuthHandler
|
|
127
|
+
};
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
interface FilesArgs {
|
|
2
|
+
basedir: string;
|
|
3
|
+
webAuthn: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Get the api side file paths and file contents to write
|
|
7
|
+
*
|
|
8
|
+
* Example return value:
|
|
9
|
+
* ```json
|
|
10
|
+
* {
|
|
11
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/auth.ts": "<file content>",
|
|
12
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/helperFunctions.ts": "<file content>",
|
|
13
|
+
* "/Users/tobbe/dev/rw-app/api/src/functions/auth.ts": "<file content>"
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const apiSideFiles: ({ basedir, webAuthn }: FilesArgs) => Promise<Record<string, string>>;
|
|
18
|
+
/**
|
|
19
|
+
* Loops through the keys in `filesRecord` and generates unique file paths if
|
|
20
|
+
* they conflict with existing files
|
|
21
|
+
*
|
|
22
|
+
* Given this input:
|
|
23
|
+
* ```json
|
|
24
|
+
* {
|
|
25
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/auth.ts": "<file content>",
|
|
26
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/helperFunctions.ts": "<file content>",
|
|
27
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/supertokens.ts": "<file content>",
|
|
28
|
+
* "/Users/tobbe/dev/rw-app/api/src/functions/auth.ts": "<file content>"
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* You could get this output, depending on what existing files there are
|
|
33
|
+
* ```json
|
|
34
|
+
* {
|
|
35
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/supertokensAuth3.ts": "<file content>",
|
|
36
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/supertokensHelperFunctions.ts": "<file content>",
|
|
37
|
+
* "/Users/tobbe/dev/rw-app/api/src/lib/supertokens2.ts": "<file content>",
|
|
38
|
+
* "/Users/tobbe/dev/rw-app/api/src/functions/auth.ts": "<file content>"
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function generateUniqueFileNames(filesRecord: Record<string, string>, provider: string): Record<string, string>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=authFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authFiles.d.ts","sourceRoot":"","sources":["../../../src/auth/authFiles.ts"],"names":[],"mappings":"AASA,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,0BAAiC,SAAS,oCAmElE,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,QAAQ,EAAE,MAAM,0BAwCjB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 authFiles_exports = {};
|
|
30
|
+
__export(authFiles_exports, {
|
|
31
|
+
apiSideFiles: () => apiSideFiles,
|
|
32
|
+
generateUniqueFileNames: () => generateUniqueFileNames
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(authFiles_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
36
|
+
var import_path = __toESM(require("path"), 1);
|
|
37
|
+
var import_pascalcase = __toESM(require("pascalcase"), 1);
|
|
38
|
+
var import_lib = require("../lib/index.js");
|
|
39
|
+
var import_paths = require("../lib/paths.js");
|
|
40
|
+
var import_project = require("../lib/project.js");
|
|
41
|
+
const apiSideFiles = async ({ basedir, webAuthn }) => {
|
|
42
|
+
const apiSrcPath = (0, import_paths.getPaths)().api.src;
|
|
43
|
+
const apiBaseTemplatePath = import_path.default.join(basedir, "templates", "api");
|
|
44
|
+
const templateDirectories = import_fs.default.readdirSync(apiBaseTemplatePath);
|
|
45
|
+
let filesRecord = {};
|
|
46
|
+
for (const dir of templateDirectories) {
|
|
47
|
+
const templateFiles = import_fs.default.readdirSync(import_path.default.join(apiBaseTemplatePath, dir));
|
|
48
|
+
const filePaths = templateFiles.filter((fileName) => {
|
|
49
|
+
const fileNameParts = fileName.split(".");
|
|
50
|
+
return fileNameParts.length <= 3 || fileNameParts.at(-3) !== "webAuthn";
|
|
51
|
+
}).map((fileName) => {
|
|
52
|
+
let outputFileName = fileName.replace(/\.template$/, "");
|
|
53
|
+
if (!(0, import_project.isTypeScriptProject)()) {
|
|
54
|
+
outputFileName = outputFileName.replace(/\.ts(x?)$/, ".js$1");
|
|
55
|
+
}
|
|
56
|
+
if (!webAuthn) {
|
|
57
|
+
return { templateFileName: fileName, outputFileName };
|
|
58
|
+
}
|
|
59
|
+
const webAuthnFileName = fileName.split(".").reverse().map((part, i) => i === 1 ? "webAuthn." + part : part).reverse().join(".");
|
|
60
|
+
if (templateFiles.includes(webAuthnFileName)) {
|
|
61
|
+
return { templateFileName: webAuthnFileName, outputFileName };
|
|
62
|
+
} else {
|
|
63
|
+
return { templateFileName: fileName, outputFileName };
|
|
64
|
+
}
|
|
65
|
+
}).map((f) => {
|
|
66
|
+
const templateFilePath = import_path.default.join(
|
|
67
|
+
apiBaseTemplatePath,
|
|
68
|
+
dir,
|
|
69
|
+
f.templateFileName
|
|
70
|
+
);
|
|
71
|
+
const outputFilePath = import_path.default.join(apiSrcPath, dir, f.outputFileName);
|
|
72
|
+
return { templateFilePath, outputFilePath };
|
|
73
|
+
});
|
|
74
|
+
for (const paths of filePaths) {
|
|
75
|
+
const content = import_fs.default.readFileSync(paths.templateFilePath, "utf8");
|
|
76
|
+
filesRecord = {
|
|
77
|
+
...filesRecord,
|
|
78
|
+
[paths.outputFilePath]: (0, import_project.isTypeScriptProject)() ? content : await (0, import_lib.transformTSToJS)(paths.outputFilePath, content)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return filesRecord;
|
|
83
|
+
};
|
|
84
|
+
function generateUniqueFileNames(filesRecord, provider) {
|
|
85
|
+
const newFilesRecord = {};
|
|
86
|
+
Object.keys(filesRecord).forEach((fullPath) => {
|
|
87
|
+
let newFullPath = fullPath;
|
|
88
|
+
let i = 1;
|
|
89
|
+
while (import_fs.default.existsSync(newFullPath)) {
|
|
90
|
+
const nameParts = import_path.default.basename(fullPath).split(".");
|
|
91
|
+
if (nameParts[0] === provider) {
|
|
92
|
+
const newFileName = provider + (i + 1) + "." + nameParts.slice(1).join(".");
|
|
93
|
+
newFullPath = import_path.default.join(import_path.default.dirname(fullPath), newFileName);
|
|
94
|
+
} else {
|
|
95
|
+
const count = i > 1 ? i : "";
|
|
96
|
+
const newFileName = provider + (0, import_pascalcase.default)(nameParts[0]) + count + "." + nameParts.slice(1).join(".");
|
|
97
|
+
newFullPath = import_path.default.join(import_path.default.dirname(fullPath), newFileName);
|
|
98
|
+
}
|
|
99
|
+
i++;
|
|
100
|
+
}
|
|
101
|
+
newFilesRecord[newFullPath] = filesRecord[fullPath];
|
|
102
|
+
});
|
|
103
|
+
return newFilesRecord;
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
apiSideFiles,
|
|
108
|
+
generateUniqueFileNames
|
|
109
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ListrRenderer, ListrTask, ListrTaskWrapper } from 'listr2';
|
|
2
|
+
export declare const getWebAppPath: () => string;
|
|
3
|
+
export declare const addApiConfig: ({ replaceExistingImport, authDecoderImport, }: {
|
|
4
|
+
replaceExistingImport: boolean;
|
|
5
|
+
authDecoderImport?: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
export declare const hasAuthProvider: (content: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Removes <AuthProvider ...> and </AuthProvider> if they exist, and un-indents
|
|
10
|
+
* the content.
|
|
11
|
+
*
|
|
12
|
+
* Exported for testing
|
|
13
|
+
*/
|
|
14
|
+
export declare const removeAuthProvider: (content: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Actually inserts the required config lines into App.{jsx,tsx}
|
|
17
|
+
* Exported for testing
|
|
18
|
+
*/
|
|
19
|
+
export declare const addConfigToWebApp: <Renderer extends typeof ListrRenderer>() => ListrTask<AuthGeneratorCtx, Renderer>;
|
|
20
|
+
export declare const createWebAuth: (basedir: string, webAuthn: boolean) => {
|
|
21
|
+
title: string;
|
|
22
|
+
task: (ctx: AuthGeneratorCtx) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export declare const addConfigToRoutes: () => {
|
|
25
|
+
title: string;
|
|
26
|
+
task: () => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Will find the templates inside `${basedir}/templates/api`,
|
|
30
|
+
* and write these files to disk with unique names if they are clashing.
|
|
31
|
+
*
|
|
32
|
+
* @returns Listr task
|
|
33
|
+
*/
|
|
34
|
+
export declare const generateAuthApiFiles: <Renderer extends typeof ListrRenderer>(basedir: string, webAuthn: boolean) => ListrTask<AuthGeneratorCtx, Renderer>;
|
|
35
|
+
export declare const addAuthConfigToGqlApi: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>(authDecoderImport?: string) => {
|
|
36
|
+
title: string;
|
|
37
|
+
task: (ctx: AuthGeneratorCtx, _task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => void;
|
|
38
|
+
};
|
|
39
|
+
export type AuthSetupMode = 'FORCE' | 'REPLACE' | 'COMBINE' | 'UNKNOWN';
|
|
40
|
+
export interface AuthGeneratorCtx {
|
|
41
|
+
setupMode: AuthSetupMode;
|
|
42
|
+
provider: string;
|
|
43
|
+
force: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const setAuthSetupMode: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>(force: boolean) => {
|
|
46
|
+
title: string;
|
|
47
|
+
task: (ctx: AuthGeneratorCtx, task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=authTasks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authTasks.d.ts","sourceRoot":"","sources":["../../../src/auth/authTasks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAmBxE,eAAO,MAAM,aAAa,cAA2B,CAAA;AAwDrD,eAAO,MAAM,YAAY,kDAGtB;IACD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,SAgDA,CAAA;AAmCD,eAAO,MAAM,eAAe,YAAa,MAAM,YAE9C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,YAAa,MAAM,WA6CjD,CAAA;AAoED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,SAAS,OAAO,aAAa,OAClC,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CA0CxC,CAAA;AAED,eAAO,MAAM,aAAa,YAAa,MAAM,YAAY,OAAO;;gBAgC1C,gBAAgB;CA0CrC,CAAA;AAED,eAAO,MAAM,iBAAiB;;;CAmB7B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,OAAO,aAAa,WAC/D,MAAM,YACL,OAAO,KAChB,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CAgDtC,CAAA;AASD,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,OAAO,aAAa,EACrC,gBAAgB,SAAS,OAAO,aAAa,sBAEzB,MAAM;;gBAInB,gBAAgB,SACd,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CAcvE,CAAA;AAEF,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,CAAA;AAEb,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,SAAS,OAAO,aAAa,EACrC,gBAAgB,SAAS,OAAO,aAAa,SAEtC,OAAO;;gBAKL,gBAAgB,QACf,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CA2CzE,CAAA"}
|