@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.
Files changed (56) hide show
  1. package/dist/lib/project.d.ts.map +1 -1
  2. package/dist/lib/project.js +2 -1
  3. package/package.json +14 -46
  4. package/dist/cjs/auth/authFiles.d.ts +0 -44
  5. package/dist/cjs/auth/authFiles.d.ts.map +0 -1
  6. package/dist/cjs/auth/authFiles.js +0 -109
  7. package/dist/cjs/auth/authTasks.d.ts +0 -49
  8. package/dist/cjs/auth/authTasks.d.ts.map +0 -1
  9. package/dist/cjs/auth/authTasks.js +0 -391
  10. package/dist/cjs/auth/setupHelpers.d.ts +0 -27
  11. package/dist/cjs/auth/setupHelpers.d.ts.map +0 -1
  12. package/dist/cjs/auth/setupHelpers.js +0 -141
  13. package/dist/cjs/index.d.ts +0 -12
  14. package/dist/cjs/index.d.ts.map +0 -1
  15. package/dist/cjs/index.js +0 -52
  16. package/dist/cjs/lib/colors.d.ts +0 -24
  17. package/dist/cjs/lib/colors.d.ts.map +0 -1
  18. package/dist/cjs/lib/colors.js +0 -52
  19. package/dist/cjs/lib/index.d.ts +0 -22
  20. package/dist/cjs/lib/index.d.ts.map +0 -1
  21. package/dist/cjs/lib/index.js +0 -147
  22. package/dist/cjs/lib/installHelpers.d.ts +0 -17
  23. package/dist/cjs/lib/installHelpers.d.ts.map +0 -1
  24. package/dist/cjs/lib/installHelpers.js +0 -65
  25. package/dist/cjs/lib/loadEnvFiles.d.ts +0 -5
  26. package/dist/cjs/lib/loadEnvFiles.d.ts.map +0 -1
  27. package/dist/cjs/lib/loadEnvFiles.js +0 -99
  28. package/dist/cjs/lib/paths.d.ts +0 -6
  29. package/dist/cjs/lib/paths.d.ts.map +0 -1
  30. package/dist/cjs/lib/paths.js +0 -42
  31. package/dist/cjs/lib/project.d.ts +0 -44
  32. package/dist/cjs/lib/project.d.ts.map +0 -1
  33. package/dist/cjs/lib/project.js +0 -268
  34. package/dist/cjs/lib/version.d.ts +0 -17
  35. package/dist/cjs/lib/version.d.ts.map +0 -1
  36. package/dist/cjs/lib/version.js +0 -107
  37. package/dist/cjs/package.json +0 -1
  38. package/dist/cjs/packageManager/display.d.ts +0 -90
  39. package/dist/cjs/packageManager/display.d.ts.map +0 -1
  40. package/dist/cjs/packageManager/display.js +0 -139
  41. package/dist/cjs/packageManager/exec.d.ts +0 -77
  42. package/dist/cjs/packageManager/exec.d.ts.map +0 -1
  43. package/dist/cjs/packageManager/exec.js +0 -152
  44. package/dist/cjs/packageManager/index.d.ts +0 -13
  45. package/dist/cjs/packageManager/index.d.ts.map +0 -1
  46. package/dist/cjs/packageManager/index.js +0 -73
  47. package/dist/cjs/packageManager/packages.d.ts +0 -39
  48. package/dist/cjs/packageManager/packages.d.ts.map +0 -1
  49. package/dist/cjs/packageManager/packages.js +0 -91
  50. package/dist/cjs/packageManager/workspaces.d.ts +0 -4
  51. package/dist/cjs/packageManager/workspaces.d.ts.map +0 -1
  52. package/dist/cjs/packageManager/workspaces.js +0 -93
  53. package/dist/cjs/telemetry/index.d.ts +0 -20
  54. package/dist/cjs/telemetry/index.d.ts.map +0 -1
  55. package/dist/cjs/telemetry/index.js +0 -64
  56. package/dist/package.json +0 -1
@@ -1,391 +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 authTasks_exports = {};
30
- __export(authTasks_exports, {
31
- addApiConfig: () => addApiConfig,
32
- addAuthConfigToGqlApi: () => addAuthConfigToGqlApi,
33
- addConfigToRoutes: () => addConfigToRoutes,
34
- addConfigToWebApp: () => addConfigToWebApp,
35
- createWebAuth: () => createWebAuth,
36
- generateAuthApiFiles: () => generateAuthApiFiles,
37
- getWebAppPath: () => getWebAppPath,
38
- hasAuthProvider: () => hasAuthProvider,
39
- removeAuthProvider: () => removeAuthProvider,
40
- setAuthSetupMode: () => setAuthSetupMode
41
- });
42
- module.exports = __toCommonJS(authTasks_exports);
43
- var import_node_fs = __toESM(require("node:fs"), 1);
44
- var import_path = __toESM(require("path"), 1);
45
- var import_prompt_adapter_enquirer = require("@listr2/prompt-adapter-enquirer");
46
- var import_project_config = require("@cedarjs/project-config");
47
- var import_colors = require("../lib/colors.js");
48
- var import_lib = require("../lib/index.js");
49
- var import_paths = require("../lib/paths.js");
50
- var import_project = require("../lib/project.js");
51
- var import_authFiles = require("./authFiles.js");
52
- const AUTH_PROVIDER_HOOK_IMPORT = `import { AuthProvider, useAuth } from './auth.js'`;
53
- const AUTH_HOOK_IMPORT = `import { useAuth } from './auth.js'`;
54
- const APOLLO_PROVIDER_COMPONENT_NAMES = [
55
- "CedarApolloProvider",
56
- "RedwoodApolloProvider"
57
- ];
58
- const getWebAppPath = () => (0, import_paths.getPaths)().web.app;
59
- function addAuthDecoderToCreateGraphQLHandler(content) {
60
- if (!new RegExp("(?=(^.*?createGraphQLHandler))\\1.*\\bauthDecoder", "s").test(
61
- content
62
- )) {
63
- return content.replace(
64
- /^(?<indentation>\s*)(loggerConfig:)(.*)$/m,
65
- `$<indentation>authDecoder,
66
- $<indentation>$2$3`
67
- );
68
- }
69
- return content;
70
- }
71
- function replaceAuthDecoderImport(content, decoderImport) {
72
- return content.replace(/^import { authDecoder .*} from .+/, decoderImport);
73
- }
74
- function replaceAuthDecoderArg(content) {
75
- return content.replace(/^(\s+)authDecoder\b.+/m, "$1authDecoder,");
76
- }
77
- const addApiConfig = ({
78
- replaceExistingImport,
79
- authDecoderImport
80
- }) => {
81
- const graphqlPath = (0, import_project.getGraphqlPath)();
82
- if (!graphqlPath) {
83
- throw new Error("Could not find your graphql file path");
84
- }
85
- const content = import_node_fs.default.readFileSync(graphqlPath).toString();
86
- let newContent = content;
87
- if (authDecoderImport) {
88
- if (replaceExistingImport) {
89
- newContent = replaceAuthDecoderImport(newContent, authDecoderImport);
90
- newContent = replaceAuthDecoderArg(newContent);
91
- }
92
- const didReplace = newContent.includes(authDecoderImport);
93
- if (!replaceExistingImport || !didReplace) {
94
- newContent = authDecoderImport + "\n" + newContent;
95
- newContent = addAuthDecoderToCreateGraphQLHandler(newContent);
96
- }
97
- }
98
- const hasCurrentUserImport = /(^import {.*?getCurrentUser(?!getCurrentUser).*?} from ['"]src\/lib\/auth(?:\.js)?['"])/s.test(
99
- newContent
100
- );
101
- if (!hasCurrentUserImport) {
102
- newContent = newContent.replace(
103
- /^(import { db } from ['"]src\/lib\/db(?:\.js)?['"])$/m,
104
- `import { getCurrentUser } from 'src/lib/auth'
105
- $1`
106
- );
107
- newContent = newContent.replace(
108
- /^(\s*)(loggerConfig:)(.*)$/m,
109
- `$1getCurrentUser,
110
- $1$2$3`
111
- );
112
- }
113
- if (newContent !== content) {
114
- import_node_fs.default.writeFileSync(graphqlPath, newContent);
115
- }
116
- };
117
- const apiSrcDoesExist = () => {
118
- return import_node_fs.default.existsSync(import_path.default.join((0, import_paths.getPaths)().api.src));
119
- };
120
- const addAuthImportToApp = (content) => {
121
- const contentLines = content.split("\n");
122
- const importIndex = contentLines.findLastIndex(
123
- (line) => /^\s*import (?!.*(?:.css['"]|.scss['"]))/.test(line)
124
- );
125
- contentLines.splice(importIndex + 1, 0, "", AUTH_PROVIDER_HOOK_IMPORT);
126
- return contentLines.join("\n");
127
- };
128
- const addAuthImportToRoutes = (content) => {
129
- const contentLines = content.split("\n");
130
- const importIndex = contentLines.findLastIndex(
131
- (line) => /^\s*import (?!.*(?:.css['"]|.scss['"]))/.test(line)
132
- );
133
- contentLines.splice(importIndex + 1, 0, "", AUTH_HOOK_IMPORT);
134
- return contentLines.join("\n");
135
- };
136
- const hasAuthProvider = (content) => {
137
- return /\s*<AuthProvider([\s>]|$)/.test(content);
138
- };
139
- const removeAuthProvider = (content) => {
140
- let remove = false;
141
- let end = "";
142
- let unindent = false;
143
- return content.split("\n").reduce((acc, line) => {
144
- let keep = !remove;
145
- if (hasAuthProvider(line)) {
146
- remove = true;
147
- keep = false;
148
- unindent = true;
149
- end = line.replace(/^(\s*)<Auth.*/s, "$1") + ">";
150
- }
151
- if (hasAuthProvider(line) && line.trimEnd().at(-1) === ">" || line.trimEnd() === end) {
152
- remove = false;
153
- }
154
- if (/\s*<\/AuthProvider>/.test(line)) {
155
- keep = false;
156
- unindent = false;
157
- }
158
- if (keep) {
159
- if (unindent) {
160
- acc.push(line.replace(" ", ""));
161
- } else {
162
- acc.push(line);
163
- }
164
- }
165
- return acc;
166
- }, []).join("\n");
167
- };
168
- const addAuthProviderToApp = (content, setupMode) => {
169
- if (setupMode === "FORCE" || setupMode === "REPLACE") {
170
- content = removeAuthProvider(content);
171
- }
172
- const match = content.match(
173
- /(\s+)(<RedwoodProvider.*?>)(.*)(<\/RedwoodProvider>)/s
174
- );
175
- if (!match) {
176
- throw new Error("Could not find <RedwoodProvider> in App.{jsx,tsx}");
177
- }
178
- if (/\s+<AuthProvider>/.test(content)) {
179
- return content;
180
- }
181
- const [
182
- _,
183
- newlineAndIndent,
184
- redwoodProviderOpen,
185
- redwoodProviderChildren,
186
- redwoodProviderClose
187
- ] = match;
188
- const redwoodProviderChildrenLines = redwoodProviderChildren.split("\n").map((line, index) => {
189
- return `${index === 0 ? "" : " "}` + line;
190
- });
191
- const renderContent = newlineAndIndent + redwoodProviderOpen + newlineAndIndent + ` <AuthProvider>` + redwoodProviderChildrenLines.join("\n") + `</AuthProvider>` + newlineAndIndent + redwoodProviderClose;
192
- return content.replace(
193
- /\s+<RedwoodProvider.*?>.*<\/RedwoodProvider>/s,
194
- renderContent
195
- );
196
- };
197
- const hasUseAuthHook = (componentName, content) => {
198
- return new RegExp(
199
- `<${componentName}.*useAuth={.*?}.*?>.*</${componentName}>`,
200
- "s"
201
- ).test(content);
202
- };
203
- const addUseAuthHook = (componentName, content) => {
204
- return content.replace(
205
- `<${componentName}`,
206
- `<${componentName} useAuth={useAuth}`
207
- );
208
- };
209
- const addConfigToWebApp = () => {
210
- return {
211
- title: "Updating web/src/App.{jsx,tsx}",
212
- task: (ctx, task) => {
213
- const webAppPath = getWebAppPath();
214
- if (!import_node_fs.default.existsSync(webAppPath)) {
215
- const ext = (0, import_project.isTypeScriptProject)() ? "tsx" : "jsx";
216
- throw new Error(`Could not find root App.${ext}`);
217
- }
218
- let content = import_node_fs.default.readFileSync(webAppPath, "utf-8");
219
- if (!content.includes(AUTH_PROVIDER_HOOK_IMPORT)) {
220
- content = addAuthImportToApp(content);
221
- }
222
- if (ctx.setupMode === "REPLACE" || ctx.setupMode === "FORCE") {
223
- content = content.replace(
224
- "import { AuthProvider } from '@cedarjs/auth'\n",
225
- ""
226
- );
227
- }
228
- content = addAuthProviderToApp(content, ctx.setupMode);
229
- const apolloProviderComponentName = APOLLO_PROVIDER_COMPONENT_NAMES.find(
230
- (componentName) => new RegExp(`\\s*<${componentName}`).test(content)
231
- );
232
- if (apolloProviderComponentName) {
233
- if (!hasUseAuthHook(apolloProviderComponentName, content)) {
234
- content = addUseAuthHook(apolloProviderComponentName, content);
235
- }
236
- } else {
237
- task.output = import_colors.colors.warning(
238
- "Could not find <CedarApolloProvider>.\nIf you are using a custom GraphQL Client you will have to make sure it gets access to your `useAuth`, if it needs it."
239
- );
240
- }
241
- import_node_fs.default.writeFileSync(webAppPath, content);
242
- }
243
- };
244
- };
245
- const createWebAuth = (basedir, webAuthn) => {
246
- const templatesBaseDir = import_path.default.join(basedir, "templates", "web");
247
- const templates = import_node_fs.default.readdirSync(templatesBaseDir);
248
- const rscEnabled = (0, import_project_config.getConfig)().experimental?.rsc?.enabled;
249
- const templateStart = "auth" + (webAuthn ? ".webAuthn" : "") + (rscEnabled ? ".rsc" : "") + ".ts";
250
- const templateFileName = templates.find((template) => {
251
- return template.startsWith(templateStart);
252
- });
253
- if (!templateFileName) {
254
- throw new Error(
255
- "Could not find the auth.ts(x) template, looking for filename starting with " + templateStart
256
- );
257
- }
258
- const templateExtension = templateFileName.split(".").at(-2);
259
- const isTSProject = (0, import_project.isTypeScriptProject)();
260
- let ext = templateExtension;
261
- if (!(0, import_project.isTypeScriptProject)()) {
262
- ext = ext?.replace("ts", "js");
263
- }
264
- return {
265
- title: `Creating web/src/auth.${ext}`,
266
- task: async (ctx) => {
267
- let authFileName = import_path.default.join((0, import_paths.getPaths)().web.src, "auth");
268
- if (ctx.setupMode === "COMBINE") {
269
- let i = 1;
270
- while ((0, import_project_config.resolveFile)(authFileName)) {
271
- const count = i > 1 ? i : "";
272
- authFileName = import_path.default.join(
273
- (0, import_paths.getPaths)().web.src,
274
- ctx.provider + "Auth" + count
275
- );
276
- i++;
277
- }
278
- }
279
- authFileName = authFileName + "." + ext;
280
- let template = import_node_fs.default.readFileSync(
281
- import_path.default.join(templatesBaseDir, templateFileName),
282
- "utf-8"
283
- );
284
- template = isTSProject ? template : await (0, import_lib.transformTSToJS)(authFileName, template);
285
- import_node_fs.default.writeFileSync(authFileName, template);
286
- }
287
- };
288
- };
289
- const addConfigToRoutes = () => {
290
- return {
291
- title: "Updating Routes file...",
292
- task: () => {
293
- const webRoutesPath = (0, import_paths.getPaths)().web.routes;
294
- let content = import_node_fs.default.readFileSync(webRoutesPath).toString();
295
- if (!content.includes(AUTH_HOOK_IMPORT)) {
296
- content = addAuthImportToRoutes(content);
297
- }
298
- if (!hasUseAuthHook("Router", content)) {
299
- content = addUseAuthHook("Router", content);
300
- }
301
- import_node_fs.default.writeFileSync(webRoutesPath, content);
302
- }
303
- };
304
- };
305
- const generateAuthApiFiles = (basedir, webAuthn) => {
306
- return {
307
- title: "Generating auth api side files...",
308
- task: async (ctx, task) => {
309
- if (!apiSrcDoesExist()) {
310
- return new Error(
311
- "Could not find api/src directory. Cannot continue setup!"
312
- );
313
- }
314
- let filesRecord = await (0, import_authFiles.apiSideFiles)({ basedir, webAuthn });
315
- let existingFiles = "FAIL";
316
- if (ctx.setupMode === "FORCE") {
317
- existingFiles = "OVERWRITE";
318
- } else if (ctx.setupMode === "REPLACE") {
319
- const filesToOverwrite = findExistingFiles(filesRecord);
320
- const prompt = task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter);
321
- const overwrite = await prompt.run({
322
- type: "confirm",
323
- message: `Overwrite existing ${filesToOverwrite.join(", ")}?`,
324
- initial: false
325
- });
326
- existingFiles = overwrite ? "OVERWRITE" : "SKIP";
327
- } else if (ctx.setupMode === "COMBINE") {
328
- const uniqueFilesRecord = (0, import_authFiles.generateUniqueFileNames)(
329
- filesRecord,
330
- ctx.provider
331
- );
332
- filesRecord = uniqueFilesRecord;
333
- existingFiles = "FAIL";
334
- }
335
- return (0, import_lib.writeFilesTask)(filesRecord, {
336
- existingFiles
337
- });
338
- }
339
- };
340
- };
341
- function findExistingFiles(filesMap) {
342
- return Object.keys(filesMap).filter((filePath) => import_node_fs.default.existsSync(filePath)).map((filePath) => filePath.replace((0, import_paths.getPaths)().base, ""));
343
- }
344
- const addAuthConfigToGqlApi = (authDecoderImport) => ({
345
- title: "Adding auth config to GraphQL API...",
346
- task: (ctx, _task) => {
347
- if ((0, import_project.graphFunctionDoesExist)()) {
348
- addApiConfig({
349
- authDecoderImport,
350
- replaceExistingImport: ctx.setupMode === "REPLACE" || ctx.setupMode === "FORCE"
351
- });
352
- } else {
353
- throw new Error(
354
- "GraphQL function not found. You will need to pass the decoder to the createGraphQLHandler function."
355
- );
356
- }
357
- }
358
- });
359
- const setAuthSetupMode = (force) => {
360
- return {
361
- title: "Checking project for existing auth...",
362
- task: async (ctx, task) => {
363
- if (force) {
364
- ctx.setupMode = "FORCE";
365
- return;
366
- }
367
- const webAppContents = import_node_fs.default.readFileSync(getWebAppPath(), "utf-8");
368
- if (hasAuthProvider(webAppContents) && ctx.setupMode === "UNKNOWN") {
369
- const setupMode = "REPLACE";
370
- ctx.setupMode = setupMode;
371
- return;
372
- } else {
373
- ctx.setupMode = "FORCE";
374
- task.skip("Setting up Auth from scratch");
375
- }
376
- }
377
- };
378
- };
379
- // Annotate the CommonJS export names for ESM import in node:
380
- 0 && (module.exports = {
381
- addApiConfig,
382
- addAuthConfigToGqlApi,
383
- addConfigToRoutes,
384
- addConfigToWebApp,
385
- createWebAuth,
386
- generateAuthApiFiles,
387
- getWebAppPath,
388
- hasAuthProvider,
389
- removeAuthProvider,
390
- setAuthSetupMode
391
- });
@@ -1,27 +0,0 @@
1
- import type { ListrTask } from 'listr2';
2
- import type { Argv } from 'yargs';
3
- import type { AuthGeneratorCtx } from './authTasks.js';
4
- export type { AuthGeneratorCtx };
5
- export declare const standardAuthBuilder: (yargs: Argv) => Argv<{
6
- force: boolean;
7
- } & {
8
- verbose: boolean;
9
- }>;
10
- export interface AuthHandlerArgs {
11
- basedir: string;
12
- forceArg: boolean;
13
- provider: string;
14
- authDecoderImport?: string;
15
- webAuthn?: boolean;
16
- webPackages?: string[];
17
- apiPackages?: string[];
18
- extraTasks?: (ListrTask<AuthGeneratorCtx> | undefined)[];
19
- notes?: string[];
20
- verbose?: boolean;
21
- }
22
- /**
23
- * basedir assumes that you must have a templates folder in that directory.
24
- * See folder structure of auth providers in packages/auth-providers/<provider>/setup/src
25
- */
26
- export declare const standardAuthHandler: ({ basedir, forceArg, provider, authDecoderImport, webAuthn, webPackages, apiPackages, extraTasks, notes, verbose, }: AuthHandlerArgs) => Promise<void>;
27
- //# sourceMappingURL=setupHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupHelpers.d.ts","sourceRoot":"","sources":["../../../src/auth/setupHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAWjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC,eAAO,MAAM,mBAAmB,GAAI,OAAO,IAAI;;;;EAoB9C,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,EAAE,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AASD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAU,qHAWvC,eAAe,kBAiFjB,CAAA"}
@@ -1,141 +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 setupHelpers_exports = {};
20
- __export(setupHelpers_exports, {
21
- standardAuthBuilder: () => standardAuthBuilder,
22
- standardAuthHandler: () => standardAuthHandler
23
- });
24
- module.exports = __toCommonJS(setupHelpers_exports);
25
- var import_listr2 = require("listr2");
26
- var import_termi_link = require("termi-link");
27
- var import_telemetry = require("@cedarjs/telemetry");
28
- var import_colors = require("../lib/colors.js");
29
- var import_installHelpers = require("../lib/installHelpers.js");
30
- var import_authTasks = require("./authTasks.js");
31
- const standardAuthBuilder = (yargs) => {
32
- return yargs.option("force", {
33
- alias: "f",
34
- default: false,
35
- description: "Overwrite existing auth configuration",
36
- type: "boolean"
37
- }).option("verbose", {
38
- alias: "v",
39
- default: false,
40
- description: "Log setup output",
41
- type: "boolean"
42
- }).epilogue(
43
- `Also see the ${(0, import_termi_link.terminalLink)(
44
- "CedarJS CLI Reference",
45
- "https://cedarjs.com/docs/cli-commands#setup-auth"
46
- )}`
47
- );
48
- };
49
- function truthy(value) {
50
- return !!value;
51
- }
52
- const standardAuthHandler = async ({
53
- basedir,
54
- forceArg,
55
- provider,
56
- authDecoderImport,
57
- webAuthn = false,
58
- webPackages = [],
59
- apiPackages = [],
60
- extraTasks,
61
- notes,
62
- verbose
63
- }) => {
64
- const tasks = new import_listr2.Listr(
65
- [
66
- (0, import_authTasks.setAuthSetupMode)(forceArg),
67
- (0, import_authTasks.generateAuthApiFiles)(basedir, webAuthn),
68
- (0, import_authTasks.addConfigToWebApp)(),
69
- (0, import_authTasks.createWebAuth)(basedir, webAuthn),
70
- (0, import_authTasks.addConfigToRoutes)(),
71
- (0, import_authTasks.addAuthConfigToGqlApi)(authDecoderImport),
72
- webPackages.length && (0, import_installHelpers.addWebPackages)(webPackages),
73
- apiPackages.length && (0, import_installHelpers.addApiPackages)(apiPackages),
74
- (webPackages.length || apiPackages.length) && import_installHelpers.installPackages,
75
- ...(extraTasks || []).filter(truthy),
76
- notes && {
77
- title: "One more thing...",
78
- task: (ctx) => {
79
- if (ctx.setupMode === "REPLACE") {
80
- notes.push(
81
- ...[
82
- "",
83
- `${import_colors.colors.warning(
84
- "Your existing auth provider has been replaced!"
85
- )}`,
86
- "You'll still need to manually remove your old auth provider's config,",
87
- "functions, and dependencies (in your web and api package.json's)."
88
- ]
89
- );
90
- }
91
- if (ctx.setupMode === "COMBINE") {
92
- notes.push(
93
- import_colors.colors.warning(
94
- `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`
95
- )
96
- );
97
- }
98
- }
99
- }
100
- ].filter(truthy),
101
- {
102
- rendererOptions: { collapseSubtasks: false },
103
- renderer: verbose ? "verbose" : "default",
104
- ctx: {
105
- setupMode: "UNKNOWN",
106
- provider,
107
- // provider name passed from CLI
108
- force: forceArg
109
- }
110
- }
111
- );
112
- try {
113
- await tasks.run();
114
- if (notes) {
115
- console.log(`
116
- ${notes.join("\n ")}
117
- `);
118
- }
119
- } catch (e) {
120
- if (isErrorWithMessage(e)) {
121
- (0, import_telemetry.errorTelemetry)(process.argv, e.message);
122
- console.error(import_colors.colors.error(e.message));
123
- }
124
- if (isErrorWithErrorCode(e)) {
125
- process.exit(e.exitCode || 1);
126
- } else {
127
- process.exit(1);
128
- }
129
- }
130
- };
131
- function isErrorWithMessage(e) {
132
- return !!e.message;
133
- }
134
- function isErrorWithErrorCode(e) {
135
- return !isNaN(e.exitCode);
136
- }
137
- // Annotate the CommonJS export names for ESM import in node:
138
- 0 && (module.exports = {
139
- standardAuthBuilder,
140
- standardAuthHandler
141
- });
@@ -1,12 +0,0 @@
1
- export * from './lib/index.js';
2
- export * from './lib/colors.js';
3
- export { loadEnvFiles } from './lib/loadEnvFiles.js';
4
- export { loadDefaultEnvFiles, loadNodeEnvDerivedEnvFile, loadUserSpecifiedEnvFiles, } from './lib/loadEnvFiles.js';
5
- export * from './lib/paths.js';
6
- export * from './lib/project.js';
7
- export * from './lib/version.js';
8
- export * from './auth/setupHelpers.js';
9
- export type { AuthHandlerArgs, AuthGeneratorCtx } from './auth/setupHelpers.js';
10
- export * from './lib/installHelpers.js';
11
- export * from './telemetry/index.js';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE/E,cAAc,yBAAyB,CAAA;AAEvC,cAAc,sBAAsB,CAAA"}
package/dist/cjs/index.js DELETED
@@ -1,52 +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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var index_exports = {};
21
- __export(index_exports, {
22
- loadDefaultEnvFiles: () => import_loadEnvFiles2.loadDefaultEnvFiles,
23
- loadEnvFiles: () => import_loadEnvFiles.loadEnvFiles,
24
- loadNodeEnvDerivedEnvFile: () => import_loadEnvFiles2.loadNodeEnvDerivedEnvFile,
25
- loadUserSpecifiedEnvFiles: () => import_loadEnvFiles2.loadUserSpecifiedEnvFiles
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
- __reExport(index_exports, require("./lib/index.js"), module.exports);
29
- __reExport(index_exports, require("./lib/colors.js"), module.exports);
30
- var import_loadEnvFiles = require("./lib/loadEnvFiles.js");
31
- var import_loadEnvFiles2 = require("./lib/loadEnvFiles.js");
32
- __reExport(index_exports, require("./lib/paths.js"), module.exports);
33
- __reExport(index_exports, require("./lib/project.js"), module.exports);
34
- __reExport(index_exports, require("./lib/version.js"), module.exports);
35
- __reExport(index_exports, require("./auth/setupHelpers.js"), module.exports);
36
- __reExport(index_exports, require("./lib/installHelpers.js"), module.exports);
37
- __reExport(index_exports, require("./telemetry/index.js"), module.exports);
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- loadDefaultEnvFiles,
41
- loadEnvFiles,
42
- loadNodeEnvDerivedEnvFile,
43
- loadUserSpecifiedEnvFiles,
44
- ...require("./lib/index.js"),
45
- ...require("./lib/colors.js"),
46
- ...require("./lib/paths.js"),
47
- ...require("./lib/project.js"),
48
- ...require("./lib/version.js"),
49
- ...require("./auth/setupHelpers.js"),
50
- ...require("./lib/installHelpers.js"),
51
- ...require("./telemetry/index.js")
52
- });
@@ -1,24 +0,0 @@
1
- /**
2
- * Canonical color/style palette for all Cedar CLI packages.
3
- *
4
- * Import from here rather than defining local copies:
5
- * import { colors } from '@cedarjs/cli-helpers'
6
- *
7
- * If you need a color that isn't here, add it here rather than
8
- * introducing a one-off in another package.
9
- */
10
- export declare const colors: {
11
- error: import("ansis").Ansis;
12
- warning: import("ansis").Ansis;
13
- highlight: import("ansis").Ansis;
14
- success: import("ansis").Ansis;
15
- info: import("ansis").Ansis;
16
- bold: import("ansis").Ansis;
17
- underline: import("ansis").Ansis;
18
- note: import("ansis").Ansis;
19
- tip: import("ansis").Ansis;
20
- important: import("ansis").Ansis;
21
- caution: import("ansis").Ansis;
22
- link: import("ansis").Ansis;
23
- };
24
- //# sourceMappingURL=colors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/lib/colors.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAalB,CAAA"}