@cedarjs/cli-helpers 7.0.1-next.466 → 7.1.0-rc.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,6 @@
1
1
  interface FilesArgs {
2
2
  basedir: string;
3
3
  webAuthn: boolean;
4
- /**
5
- * Selects the `*.oauth.*` template variant, the same way `webAuthn` selects
6
- * the `*.webAuthn.*` variant. When both are true, the most specific
7
- * template available is preferred (`*.webAuthn.oauth.*`), falling back to
8
- * a single-variant or the base template when a more specific one doesn't
9
- * exist for a given template file.
10
- */
11
- oauth?: boolean;
12
4
  }
13
5
  /**
14
6
  * Get the api side file paths and file contents to write
@@ -22,7 +14,7 @@ interface FilesArgs {
22
14
  * }
23
15
  * ```
24
16
  */
25
- export declare const apiSideFiles: ({ basedir, webAuthn, oauth, }: FilesArgs) => Promise<Record<string, string>>;
17
+ export declare const apiSideFiles: ({ basedir, webAuthn }: FilesArgs) => Promise<Record<string, string>>;
26
18
  /**
27
19
  * Loops through the keys in `filesRecord` and generates unique file paths if
28
20
  * they conflict with existing files
@@ -1 +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;IACjB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AA+DD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAU,+BAIhC,SAAS,oCA4CX,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,QAAQ,EAAE,MAAM,0BAwCjB"}
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,GAAU,uBAAuB,SAAS,oCAmElE,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,QAAQ,EAAE,MAAM,0BAwCjB"}
@@ -4,59 +4,37 @@ import pascalcase from "pascalcase";
4
4
  import { transformTSToJS } from "../lib/index.js";
5
5
  import { getPaths } from "../lib/paths.js";
6
6
  import { isTypeScriptProject } from "../lib/project.js";
7
- const VARIANT_TAGS = ["webAuthn", "oauth"];
8
- function parseTemplateFileName(fileName) {
9
- const parts = fileName.split(".");
10
- const baseName = parts[0];
11
- const ext = parts.at(-2);
12
- const tags = parts.slice(1, -2).filter((part) => VARIANT_TAGS.includes(part));
13
- return { baseName, tags, ext };
14
- }
15
- function pickTemplateVariants(templateFiles, activeTags) {
16
- const candidatesByKey = /* @__PURE__ */ new Map();
17
- for (const fileName of templateFiles) {
18
- const { baseName, tags, ext } = parseTemplateFileName(fileName);
19
- const key = `${baseName}.${ext}`;
20
- const candidates = candidatesByKey.get(key) ?? [];
21
- candidates.push({ fileName, tags });
22
- candidatesByKey.set(key, candidates);
23
- }
24
- const picked = [];
25
- for (const candidates of candidatesByKey.values()) {
26
- const applicable = candidates.filter(
27
- (candidate) => candidate.tags.every((tag) => activeTags.includes(tag))
28
- );
29
- const mostSpecific = applicable.reduce(
30
- (best, candidate) => candidate.tags.length > best.tags.length ? candidate : best
31
- );
32
- picked.push(mostSpecific);
33
- }
34
- return picked;
35
- }
36
- const apiSideFiles = async ({
37
- basedir,
38
- webAuthn,
39
- oauth = false
40
- }) => {
7
+ const apiSideFiles = async ({ basedir, webAuthn }) => {
41
8
  const apiSrcPath = getPaths().api.src;
42
9
  const apiBaseTemplatePath = path.join(basedir, "templates", "api");
43
10
  const templateDirectories = fs.readdirSync(apiBaseTemplatePath);
44
11
  let filesRecord = {};
45
- const activeTags = [
46
- ...webAuthn ? ["webAuthn"] : [],
47
- ...oauth ? ["oauth"] : []
48
- ];
49
12
  for (const dir of templateDirectories) {
50
13
  const templateFiles = fs.readdirSync(path.join(apiBaseTemplatePath, dir));
51
- const pickedVariants = pickTemplateVariants(templateFiles, activeTags);
52
- const filePaths = pickedVariants.map(({ fileName }) => {
53
- const { baseName, ext } = parseTemplateFileName(fileName);
54
- let outputFileName = `${baseName}.${ext}`;
14
+ const filePaths = templateFiles.filter((fileName) => {
15
+ const fileNameParts = fileName.split(".");
16
+ return fileNameParts.length <= 3 || fileNameParts.at(-3) !== "webAuthn";
17
+ }).map((fileName) => {
18
+ let outputFileName = fileName.replace(/\.template$/, "");
55
19
  if (!isTypeScriptProject()) {
56
20
  outputFileName = outputFileName.replace(/\.ts(x?)$/, ".js$1");
57
21
  }
58
- const templateFilePath = path.join(apiBaseTemplatePath, dir, fileName);
59
- const outputFilePath = path.join(apiSrcPath, dir, outputFileName);
22
+ if (!webAuthn) {
23
+ return { templateFileName: fileName, outputFileName };
24
+ }
25
+ const webAuthnFileName = fileName.split(".").reverse().map((part, i) => i === 1 ? "webAuthn." + part : part).reverse().join(".");
26
+ if (templateFiles.includes(webAuthnFileName)) {
27
+ return { templateFileName: webAuthnFileName, outputFileName };
28
+ } else {
29
+ return { templateFileName: fileName, outputFileName };
30
+ }
31
+ }).map((f) => {
32
+ const templateFilePath = path.join(
33
+ apiBaseTemplatePath,
34
+ dir,
35
+ f.templateFileName
36
+ );
37
+ const outputFilePath = path.join(apiSrcPath, dir, f.outputFileName);
60
38
  return { templateFilePath, outputFilePath };
61
39
  });
62
40
  for (const paths of filePaths) {
@@ -1,5 +1,4 @@
1
1
  import type { ListrRenderer, ListrTask, ListrTaskWrapper } from 'listr2';
2
- import type { ExistingFiles } from '../lib/index.js';
3
2
  export declare const getWebAppPath: () => string;
4
3
  export declare const addApiConfig: ({ replaceExistingImport, authDecoderImport, }: {
5
4
  replaceExistingImport: boolean;
@@ -32,15 +31,7 @@ export declare const addConfigToRoutes: () => {
32
31
  *
33
32
  * @returns Listr task
34
33
  */
35
- export declare const generateAuthApiFiles: <Renderer extends typeof ListrRenderer>(basedir: string, webAuthn: boolean, oauth?: boolean) => ListrTask<AuthGeneratorCtx, Renderer>;
36
- /**
37
- * Exported for testing
38
- *
39
- * @returns `true` if writing `filesRecord` with the given `existingFiles`
40
- * strategy writes `api/src/lib/auth.{ts,js}`, which is where the auth
41
- * provider's `requireAuth` function lives
42
- */
43
- export declare function writesApiAuthLib(filesRecord: Record<string, string>, existingFiles: ExistingFiles): boolean;
34
+ export declare const generateAuthApiFiles: <Renderer extends typeof ListrRenderer>(basedir: string, webAuthn: boolean) => ListrTask<AuthGeneratorCtx, Renderer>;
44
35
  export declare const addAuthConfigToGqlApi: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>(authDecoderImport?: string) => {
45
36
  title: string;
46
37
  task: (ctx: AuthGeneratorCtx, _task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => void;
@@ -50,36 +41,9 @@ export interface AuthGeneratorCtx {
50
41
  setupMode: AuthSetupMode;
51
42
  provider: string;
52
43
  force: boolean;
53
- /**
54
- * Set by `generateAuthApiFiles`. `true` when setup writes the auth
55
- * provider's `api/src/lib/auth.{ts,js}` file, replacing any existing
56
- * `requireAuth` implementation
57
- */
58
- apiAuthLibWritten?: boolean;
59
44
  }
60
45
  export declare const setAuthSetupMode: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>(force: boolean) => {
61
46
  title: string;
62
47
  task: (ctx: AuthGeneratorCtx, task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => Promise<void>;
63
48
  };
64
- /**
65
- * Exported for testing
66
- *
67
- * @param content - The contents of requireAuth.test.{ts,js}
68
- * @returns The content with the stub test case replaced, or `undefined` if
69
- * the unmodified stub test case isn't part of the content
70
- */
71
- export declare const replaceStubRequireAuthTestCase: (content: string) => string | undefined;
72
- /**
73
- * New Cedar apps ship with a test for the `requireAuth` directive that
74
- * asserts the behavior of the stub `requireAuth` function. Setting up auth
75
- * replaces that stub, so this task replaces the stub test case with test
76
- * cases matching the real implementation. The test is only updated when
77
- * setup writes `api/src/lib/auth.{ts,js}` (for example, not when the user
78
- * declines overwriting existing files). Test files that don't contain the
79
- * unmodified stub test case are left as they are.
80
- */
81
- export declare const updateRequireAuthTest: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>() => {
82
- title: string;
83
- task: (ctx: AuthGeneratorCtx, task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => void;
84
- };
85
49
  //# sourceMappingURL=authTasks.d.ts.map
@@ -1 +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;AAKxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAsBpD,eAAO,MAAM,aAAa,cAA2B,CAAA;AAwDrD,eAAO,MAAM,YAAY,GAAI,+CAG1B;IACD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,SAgDA,CAAA;AAmCD,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,YAE9C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,WA6CjD,CAAA;AAuED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,SAAS,OAAO,aAAa,OAClC,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CA8CxC,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,UAAU,O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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,EAE7C,OAAO,OAAO;;gBAKL,gBAAgB,QACf,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CA2CzE,CAAA"}
@@ -264,7 +264,7 @@ const addConfigToRoutes = () => {
264
264
  }
265
265
  };
266
266
  };
267
- const generateAuthApiFiles = (basedir, webAuthn, oauth = false) => {
267
+ const generateAuthApiFiles = (basedir, webAuthn) => {
268
268
  return {
269
269
  title: "Generating auth api side files...",
270
270
  task: async (ctx, task) => {
@@ -273,7 +273,7 @@ const generateAuthApiFiles = (basedir, webAuthn, oauth = false) => {
273
273
  "Could not find api/src directory. Cannot continue setup!"
274
274
  );
275
275
  }
276
- let filesRecord = await apiSideFiles({ basedir, webAuthn, oauth });
276
+ let filesRecord = await apiSideFiles({ basedir, webAuthn });
277
277
  let existingFiles = "FAIL";
278
278
  if (ctx.setupMode === "FORCE") {
279
279
  existingFiles = "OVERWRITE";
@@ -294,21 +294,12 @@ const generateAuthApiFiles = (basedir, webAuthn, oauth = false) => {
294
294
  filesRecord = uniqueFilesRecord;
295
295
  existingFiles = "FAIL";
296
296
  }
297
- ctx.apiAuthLibWritten = writesApiAuthLib(filesRecord, existingFiles);
298
297
  return writeFilesTask(filesRecord, {
299
298
  existingFiles
300
299
  });
301
300
  }
302
301
  };
303
302
  };
304
- function writesApiAuthLib(filesRecord, existingFiles) {
305
- const authLibPaths = ["ts", "js"].map(
306
- (ext) => path.join(getPaths().api.src, "lib", `auth.${ext}`)
307
- );
308
- return Object.keys(filesRecord).some(
309
- (filePath) => authLibPaths.includes(filePath) && (existingFiles === "OVERWRITE" || !fs.existsSync(filePath))
310
- );
311
- }
312
303
  function findExistingFiles(filesMap) {
313
304
  return Object.keys(filesMap).filter((filePath) => fs.existsSync(filePath)).map((filePath) => filePath.replace(getPaths().base, ""));
314
305
  }
@@ -347,65 +338,6 @@ const setAuthSetupMode = (force) => {
347
338
  }
348
339
  };
349
340
  };
350
- const STUB_REQUIRE_AUTH_TEST_CASE = ` it('requireAuth has stub implementation. Should not throw when current user', () => {
351
- // If you want to set values in context, pass it through e.g.
352
- // mockRedwoodDirective(requireAuth, { context: { currentUser: { id: 1, name: 'Lebron McGretzky' } }})
353
- const mockExecution = mockRedwoodDirective(requireAuth, { context: {} })
354
-
355
- expect(mockExecution).not.toThrowError()
356
- })`;
357
- const REQUIRE_AUTH_TEST_CASES = ` it('throws when there is no current user', () => {
358
- const mockExecution = mockRedwoodDirective(requireAuth, { context: {} })
359
-
360
- expect(mockExecution).toThrowError("You don't have permission to do that.")
361
- })
362
-
363
- it('does not throw when there is a current user', () => {
364
- // The mocked user should have the same shape as what getCurrentUser()
365
- // in api/src/lib/auth returns
366
- const mockExecution = mockRedwoodDirective(requireAuth, {
367
- context: { currentUser: { id: 1 } },
368
- })
369
-
370
- expect(mockExecution).not.toThrowError()
371
- })`;
372
- const replaceStubRequireAuthTestCase = (content) => {
373
- const eol = content.includes("\r\n") ? "\r\n" : "\n";
374
- const normalizedContent = content.replaceAll("\r\n", "\n");
375
- if (!normalizedContent.includes(STUB_REQUIRE_AUTH_TEST_CASE)) {
376
- return void 0;
377
- }
378
- return normalizedContent.replace(STUB_REQUIRE_AUTH_TEST_CASE, REQUIRE_AUTH_TEST_CASES).replaceAll("\n", eol);
379
- };
380
- const updateRequireAuthTest = () => ({
381
- title: "Updating requireAuth directive test...",
382
- task: (ctx, task) => {
383
- if (!ctx.apiAuthLibWritten) {
384
- task.skip(
385
- "Keeping the requireAuth directive test as is, because the existing requireAuth implementation is kept"
386
- );
387
- return;
388
- }
389
- const testFilePath = ["ts", "js"].map(
390
- (ext) => path.join(
391
- getPaths().api.directives,
392
- "requireAuth",
393
- `requireAuth.test.${ext}`
394
- )
395
- ).find((filePath) => fs.existsSync(filePath));
396
- if (!testFilePath) {
397
- task.skip("No requireAuth directive test found");
398
- return;
399
- }
400
- const content = fs.readFileSync(testFilePath, "utf-8");
401
- const newContent = replaceStubRequireAuthTestCase(content);
402
- if (newContent === void 0) {
403
- task.skip("Keeping the customized requireAuth directive test as is");
404
- return;
405
- }
406
- fs.writeFileSync(testFilePath, newContent);
407
- }
408
- });
409
341
  export {
410
342
  addApiConfig,
411
343
  addAuthConfigToGqlApi,
@@ -416,8 +348,5 @@ export {
416
348
  getWebAppPath,
417
349
  hasAuthProvider,
418
350
  removeAuthProvider,
419
- replaceStubRequireAuthTestCase,
420
- setAuthSetupMode,
421
- updateRequireAuthTest,
422
- writesApiAuthLib
351
+ setAuthSetupMode
423
352
  };
@@ -13,7 +13,6 @@ export interface AuthHandlerArgs {
13
13
  provider: string;
14
14
  authDecoderImport?: string;
15
15
  webAuthn?: boolean;
16
- oauth?: boolean;
17
16
  webPackages?: string[];
18
17
  apiPackages?: string[];
19
18
  extraTasks?: (ListrTask<AuthGeneratorCtx> | undefined)[];
@@ -24,5 +23,5 @@ export interface AuthHandlerArgs {
24
23
  * basedir assumes that you must have a templates folder in that directory.
25
24
  * See folder structure of auth providers in packages/auth-providers/<provider>/setup/src
26
25
  */
27
- export declare const standardAuthHandler: ({ basedir, forceArg, provider, authDecoderImport, webAuthn, oauth, webPackages, apiPackages, extraTasks, notes, verbose, }: AuthHandlerArgs) => Promise<void>;
26
+ export declare const standardAuthHandler: ({ basedir, forceArg, provider, authDecoderImport, webAuthn, webPackages, apiPackages, extraTasks, notes, verbose, }: AuthHandlerArgs) => Promise<void>;
28
27
  //# sourceMappingURL=setupHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupHelpers.d.ts","sourceRoot":"","sources":["../../src/auth/setupHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,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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"}
@@ -13,8 +13,7 @@ import {
13
13
  addConfigToWebApp,
14
14
  setAuthSetupMode,
15
15
  createWebAuth,
16
- generateAuthApiFiles,
17
- updateRequireAuthTest
16
+ generateAuthApiFiles
18
17
  } from "./authTasks.js";
19
18
  const standardAuthBuilder = (yargs) => {
20
19
  return yargs.option("force", {
@@ -43,7 +42,6 @@ const standardAuthHandler = async ({
43
42
  provider,
44
43
  authDecoderImport,
45
44
  webAuthn = false,
46
- oauth = false,
47
45
  webPackages = [],
48
46
  apiPackages = [],
49
47
  extraTasks,
@@ -53,8 +51,7 @@ const standardAuthHandler = async ({
53
51
  const tasks = new Listr(
54
52
  [
55
53
  setAuthSetupMode(forceArg),
56
- generateAuthApiFiles(basedir, webAuthn, oauth),
57
- updateRequireAuthTest(),
54
+ generateAuthApiFiles(basedir, webAuthn),
58
55
  addConfigToWebApp(),
59
56
  createWebAuth(basedir, webAuthn),
60
57
  addConfigToRoutes(),
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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/index.js ADDED
@@ -0,0 +1,20 @@
1
+ export * from "./lib/index.js";
2
+ export * from "./lib/colors.js";
3
+ import { loadEnvFiles } from "./lib/loadEnvFiles.js";
4
+ import {
5
+ loadDefaultEnvFiles,
6
+ loadNodeEnvDerivedEnvFile,
7
+ loadUserSpecifiedEnvFiles
8
+ } from "./lib/loadEnvFiles.js";
9
+ export * from "./lib/paths.js";
10
+ export * from "./lib/project.js";
11
+ export * from "./lib/version.js";
12
+ export * from "./auth/setupHelpers.js";
13
+ export * from "./lib/installHelpers.js";
14
+ export * from "./telemetry/index.js";
15
+ export {
16
+ loadDefaultEnvFiles,
17
+ loadEnvFiles,
18
+ loadNodeEnvDerivedEnvFile,
19
+ loadUserSpecifiedEnvFiles
20
+ };
@@ -2,7 +2,7 @@
2
2
  * Canonical color/style palette for all Cedar CLI packages.
3
3
  *
4
4
  * Import from here rather than defining local copies:
5
- * import { colors } from '@cedarjs/cli-helpers/colors'
5
+ * import { colors } from '@cedarjs/cli-helpers'
6
6
  *
7
7
  * If you need a color that isn't here, add it here rather than
8
8
  * introducing a one-off in another package.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAEd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAW9B,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,6BAgBhE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,oBAsB9B,CAAA;AAED,eAAO,MAAM,QAAQ,GACnB,kBAAkB,MAAM,EACxB,kBAAkB,MAAM,KACvB,OAAO,CAAC,MAAM,CAwBhB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,SAAS,OAAO,aAAa,EAC7D,QAAQ,MAAM,EACd,UAAU,MAAM,EAChB,oBAA4B;IAAE,aAAa,CAAC,EAAE,aAAa,CAAA;CAAO,EAGlE,OAAM,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAI/C,SAoBF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,OAAO,aAAa,EAClE,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,SAAS;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,qCAuB1C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAEd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAU9B,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,6BA8BhE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,oBAsB9B,CAAA;AAED,eAAO,MAAM,QAAQ,GACnB,kBAAkB,MAAM,EACxB,kBAAkB,MAAM,KACvB,OAAO,CAAC,MAAM,CAwBhB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,SAAS,OAAO,aAAa,EAC7D,QAAQ,MAAM,EACd,UAAU,MAAM,EAChB,oBAA4B;IAAE,aAAa,CAAC,EAAE,aAAa,CAAA;CAAO,EAGlE,OAAM,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAI/C,SAoBF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,OAAO,aAAa,EAClE,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,SAAS;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,qCAuB1C,CAAA"}
package/dist/lib/index.js CHANGED
@@ -1,23 +1,37 @@
1
1
  import fs from "node:fs";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import path from "path";
4
+ import * as babel from "@babel/core";
4
5
  import { Listr } from "listr2";
5
6
  import { format } from "prettier";
6
7
  import { colors } from "./colors.js";
7
8
  import { getPaths } from "./paths.js";
8
- import { transpileTSToJS } from "./transpileTSToJS.js";
9
9
  const transformTSToJS = (filename, content) => {
10
10
  if (!content) {
11
11
  return content;
12
12
  }
13
- let code;
14
- try {
15
- code = transpileTSToJS(filename, content);
16
- } catch (e) {
17
- console.error(colors.error(e instanceof Error ? e.message : String(e)));
13
+ const babelFileResult = babel.transform(content, {
14
+ filename,
15
+ // If you ran `yarn cedar generate` in `./web` transformSync would import the `.babelrc.js` file,
16
+ // in `./web`? despite us setting `configFile: false`.
17
+ cwd: process.env.NODE_ENV === "test" ? void 0 : getPaths().base,
18
+ configFile: false,
19
+ plugins: [
20
+ [
21
+ "@babel/plugin-transform-typescript",
22
+ {
23
+ isTSX: true,
24
+ allExtensions: true
25
+ }
26
+ ]
27
+ ],
28
+ retainLines: true
29
+ });
30
+ if (!babelFileResult?.code) {
31
+ console.error(colors.error(`Could not transform ${filename} to JS`));
18
32
  process.exit(1);
19
33
  }
20
- return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), code);
34
+ return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), babelFileResult.code);
21
35
  };
22
36
  const getPrettierOptions = async () => {
23
37
  try {
@@ -25,10 +39,10 @@ const getPrettierOptions = async () => {
25
39
  const mjsPath = path.join(getPaths().base, "prettier.config.mjs");
26
40
  const prettierConfigPath = fs.existsSync(cjsPath) ? cjsPath : mjsPath;
27
41
  const { default: options } = await import(pathToFileURL(prettierConfigPath).href);
28
- if (options.tailwindStylesheet?.startsWith(".")) {
29
- options.tailwindStylesheet = path.join(
42
+ if (options.tailwindConfig?.startsWith(".")) {
43
+ options.tailwindConfig = path.join(
30
44
  process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd(),
31
- options.tailwindStylesheet
45
+ options.tailwindConfig
32
46
  );
33
47
  }
34
48
  return options;
@@ -1,6 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
- import { rangesIntersect, sort, tryParse } from "verkit";
3
+ import semver from "semver";
4
4
  import { getPaths } from "@cedarjs/project-config";
5
5
  function getCorrespondingTag(version, distTags) {
6
6
  return Object.entries(distTags).find(([_, v]) => v === version)?.[0];
@@ -12,7 +12,7 @@ async function getCompatibilityData(packageName, preferredVersionOrTag) {
12
12
  })
13
13
  );
14
14
  const projectRedwoodVersion = projectPackageJson.devDependencies["@cedarjs/core"];
15
- const semverVersion = tryParse(preferredVersionOrTag);
15
+ const semverVersion = semver.parse(preferredVersionOrTag);
16
16
  const isUsingTag = semverVersion === null;
17
17
  const res = await fetch(`https://registry.npmjs.org/${packageName}`);
18
18
  const packument = await res.json();
@@ -34,7 +34,7 @@ async function getCompatibilityData(packageName, preferredVersionOrTag) {
34
34
  }
35
35
  const preferredVersion = isUsingTag ? packument["dist-tags"][preferredVersionOrTag] : preferredVersionOrTag;
36
36
  const packageRedwoodSpecification = packument.versions[preferredVersion].engines?.redwoodjs;
37
- if (packageRedwoodSpecification !== void 0 && rangesIntersect(projectRedwoodVersion, packageRedwoodSpecification)) {
37
+ if (packageRedwoodSpecification !== void 0 && semver.intersects(projectRedwoodVersion, packageRedwoodSpecification)) {
38
38
  const tag = getCorrespondingTag(preferredVersion, packument["dist-tags"]);
39
39
  return {
40
40
  preferred: {
@@ -47,13 +47,13 @@ async function getCompatibilityData(packageName, preferredVersionOrTag) {
47
47
  }
48
48
  };
49
49
  }
50
- const versions = sort(Object.keys(packument.versions));
50
+ const versions = semver.sort(Object.keys(packument.versions));
51
51
  for (let i = versions.length - 1; i >= 0; i--) {
52
52
  const redwoodVersionRequired = packument.versions[versions[i]].engines?.redwoodjs;
53
53
  if (redwoodVersionRequired === void 0) {
54
54
  continue;
55
55
  }
56
- if (rangesIntersect(projectRedwoodVersion, redwoodVersionRequired)) {
56
+ if (semver.intersects(projectRedwoodVersion, redwoodVersionRequired)) {
57
57
  return {
58
58
  preferred: {
59
59
  tag: getCorrespondingTag(preferredVersion, packument["dist-tags"]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli-helpers",
3
- "version": "7.0.1-next.466",
3
+ "version": "7.1.0-rc.32",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -9,6 +9,12 @@
9
9
  "license": "MIT",
10
10
  "type": "module",
11
11
  "exports": {
12
+ ".": {
13
+ "default": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
12
18
  "./loadEnvFiles": {
13
19
  "default": {
14
20
  "types": "./dist/lib/loadEnvFiles.d.ts",
@@ -50,68 +56,9 @@
50
56
  "types": "./dist/packageManager/workspaces.d.ts",
51
57
  "default": "./dist/packageManager/workspaces.js"
52
58
  }
53
- },
54
- "./fileHelpers": {
55
- "default": {
56
- "types": "./dist/lib/index.d.ts",
57
- "default": "./dist/lib/index.js"
58
- }
59
- },
60
- "./colors": {
61
- "default": {
62
- "types": "./dist/lib/colors.d.ts",
63
- "default": "./dist/lib/colors.js"
64
- }
65
- },
66
- "./paths": {
67
- "default": {
68
- "types": "./dist/lib/paths.d.ts",
69
- "default": "./dist/lib/paths.js"
70
- }
71
- },
72
- "./project": {
73
- "default": {
74
- "types": "./dist/lib/project.d.ts",
75
- "default": "./dist/lib/project.js"
76
- }
77
- },
78
- "./transpileTSToJS": {
79
- "default": {
80
- "types": "./dist/lib/transpileTSToJS.d.ts",
81
- "default": "./dist/lib/transpileTSToJS.js"
82
- }
83
- },
84
- "./tty": {
85
- "default": {
86
- "types": "./dist/lib/tty.d.ts",
87
- "default": "./dist/lib/tty.js"
88
- }
89
- },
90
- "./version": {
91
- "default": {
92
- "types": "./dist/lib/version.d.ts",
93
- "default": "./dist/lib/version.js"
94
- }
95
- },
96
- "./auth/setupHelpers": {
97
- "default": {
98
- "types": "./dist/auth/setupHelpers.d.ts",
99
- "default": "./dist/auth/setupHelpers.js"
100
- }
101
- },
102
- "./installHelpers": {
103
- "default": {
104
- "types": "./dist/lib/installHelpers.d.ts",
105
- "default": "./dist/lib/installHelpers.js"
106
- }
107
- },
108
- "./telemetry": {
109
- "default": {
110
- "types": "./dist/telemetry/index.d.ts",
111
- "default": "./dist/telemetry/index.js"
112
- }
113
59
  }
114
60
  },
61
+ "types": "./dist/index.d.ts",
115
62
  "files": [
116
63
  "dist"
117
64
  ],
@@ -125,9 +72,10 @@
125
72
  "test:watch": "vitest watch"
126
73
  },
127
74
  "dependencies": {
128
- "@cedarjs/project-config": "7.0.1-next.466",
129
- "@cedarjs/telemetry": "7.0.1-next.466",
130
- "@listr2/prompt-adapter-enquirer": "4.3.3",
75
+ "@babel/core": "^7.26.10",
76
+ "@cedarjs/project-config": "7.1.0-rc.32",
77
+ "@cedarjs/telemetry": "7.1.0-rc.32",
78
+ "@listr2/prompt-adapter-enquirer": "4.3.2",
131
79
  "@opentelemetry/api": "1.9.1",
132
80
  "ansis": "4.4.0",
133
81
  "dotenv": "16.6.1",
@@ -137,19 +85,19 @@
137
85
  "listr2": "10.2.2",
138
86
  "lodash": "4.18.1",
139
87
  "pascalcase": "1.0.0",
140
- "prettier": "3.9.10",
88
+ "prettier": "3.9.8",
141
89
  "prompts": "2.4.2",
142
- "smol-toml": "1.9.1",
143
- "sucrase": "3.35.1",
90
+ "semver": "7.8.5",
91
+ "smol-toml": "1.8.0",
144
92
  "termi-link": "1.1.0",
145
- "verkit": "0.5.0",
146
93
  "yargs-parser": "21.1.1"
147
94
  },
148
95
  "devDependencies": {
149
- "@cedarjs/framework-tools": "7.0.1-next.466",
96
+ "@cedarjs/framework-tools": "7.1.0-rc.32",
150
97
  "@types/dotenv-defaults": "^5.0.0",
151
- "@types/lodash": "4.17.26",
98
+ "@types/lodash": "4.17.25",
152
99
  "@types/pascalcase": "1.0.3",
100
+ "@types/semver": "^7",
153
101
  "@types/yargs": "17.0.35",
154
102
  "@types/yargs-parser": "21.0.3",
155
103
  "prettier-plugin-tailwindcss": "0.8.1",
@@ -1,18 +0,0 @@
1
- /**
2
- * Strips the TypeScript syntax from `content` and returns the resulting
3
- * JavaScript source. Everything that is not TypeScript syntax, including JSX,
4
- * comments, blank lines and indentation, is kept byte-for-byte, so the output
5
- * only needs formatting.
6
- *
7
- * `import type` statements, `type` specifiers and imports whose bindings are
8
- * only used as types are removed. Lines that only held removed syntax (for
9
- * example an `import type` line or an `interface` body) are dropped so they
10
- * do not turn into stray blank lines.
11
- *
12
- * `filename` is used for error messages. The content is always parsed as TSX
13
- * because templates can contain JSX regardless of their extension.
14
- *
15
- * Throws when sucrase reports a syntax error.
16
- */
17
- export declare function transpileTSToJS(filename: string, content: string): string;
18
- //# sourceMappingURL=transpileTSToJS.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transpileTSToJS.d.ts","sourceRoot":"","sources":["../../src/lib/transpileTSToJS.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAwBhE"}
@@ -1,38 +0,0 @@
1
- import { transform } from "sucrase";
2
- const BLANK_LINE_REGEX = /^[ \t]*$/;
3
- function transpileTSToJS(filename, content) {
4
- let code;
5
- try {
6
- code = transform(content, {
7
- // `jsx` is required to parse JSX at all. `jsxRuntime: 'preserve'` keeps
8
- // the JSX untouched so the project's own build compiles it.
9
- transforms: ["typescript", "jsx"],
10
- jsxRuntime: "preserve",
11
- // Keep modern ECMAScript syntax (optional chaining, class fields, ...)
12
- // as written.
13
- disableESTransforms: true,
14
- keepUnusedImports: false,
15
- filePath: filename
16
- }).code;
17
- } catch (e) {
18
- const message = e instanceof Error ? e.message : String(e);
19
- throw new Error(
20
- `Could not transform ${filename} from TypeScript to JavaScript:
21
- ${message}`
22
- );
23
- }
24
- return dropEmptiedLines(content, code);
25
- }
26
- function dropEmptiedLines(input, output) {
27
- const inputLines = input.split("\n");
28
- const outputLines = output.split("\n");
29
- if (inputLines.length !== outputLines.length) {
30
- return output;
31
- }
32
- return outputLines.filter(
33
- (line, index) => !BLANK_LINE_REGEX.test(line) || BLANK_LINE_REGEX.test(inputLines[index])
34
- ).join("\n");
35
- }
36
- export {
37
- transpileTSToJS
38
- };
package/dist/lib/tty.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Prompting libraries (e.g. `prompts`) hang indefinitely when stdin isn't a
3
- * TTY - piped input, CI, or a backgrounded process never sends a keypress,
4
- * so the prompt neither resolves nor throws.
5
- *
6
- * Call this immediately before any interactive confirm/prompt that's only
7
- * reached when a flag was left unset, so a non-interactive invocation exits
8
- * with a clear, actionable error instead of hanging.
9
- */
10
- export declare function requireTTYOrExit(flagHint: string): void;
11
- //# sourceMappingURL=tty.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tty.d.ts","sourceRoot":"","sources":["../../src/lib/tty.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAYvD"}
package/dist/lib/tty.js DELETED
@@ -1,16 +0,0 @@
1
- import { errorTelemetry } from "@cedarjs/telemetry";
2
- import { colors } from "./colors.js";
3
- function requireTTYOrExit(flagHint) {
4
- if (process.stdin.isTTY) {
5
- return;
6
- }
7
- const error = new Error(
8
- `Cannot prompt for confirmation in a non-interactive terminal. Please pass ${flagHint} explicitly.`
9
- );
10
- errorTelemetry(process.argv, error.message);
11
- console.error(colors.error(error.message));
12
- process.exit(1);
13
- }
14
- export {
15
- requireTTYOrExit
16
- };