@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.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/auth/authFiles.d.ts +44 -0
  4. package/dist/auth/authFiles.d.ts.map +1 -0
  5. package/dist/auth/authFiles.js +74 -0
  6. package/dist/auth/authTasks.d.ts +49 -0
  7. package/dist/auth/authTasks.d.ts.map +1 -0
  8. package/dist/auth/authTasks.js +345 -0
  9. package/dist/auth/setupHelpers.d.ts +26 -0
  10. package/dist/auth/setupHelpers.d.ts.map +1 -0
  11. package/dist/auth/setupHelpers.js +127 -0
  12. package/dist/build.d.ts +2 -0
  13. package/dist/build.d.ts.map +1 -0
  14. package/dist/cjs/auth/authFiles.d.ts +44 -0
  15. package/dist/cjs/auth/authFiles.d.ts.map +1 -0
  16. package/dist/cjs/auth/authFiles.js +109 -0
  17. package/dist/cjs/auth/authTasks.d.ts +49 -0
  18. package/dist/cjs/auth/authTasks.d.ts.map +1 -0
  19. package/dist/cjs/auth/authTasks.js +384 -0
  20. package/dist/cjs/auth/setupHelpers.d.ts +26 -0
  21. package/dist/cjs/auth/setupHelpers.d.ts.map +1 -0
  22. package/dist/cjs/auth/setupHelpers.js +151 -0
  23. package/dist/cjs/index.d.ts +12 -0
  24. package/dist/cjs/index.d.ts.map +1 -0
  25. package/dist/cjs/index.js +52 -0
  26. package/dist/cjs/lib/colors.d.ts +23 -0
  27. package/dist/cjs/lib/colors.d.ts.map +1 -0
  28. package/dist/cjs/lib/colors.js +52 -0
  29. package/dist/cjs/lib/index.d.ts +21 -0
  30. package/dist/cjs/lib/index.d.ts.map +1 -0
  31. package/dist/cjs/lib/index.js +140 -0
  32. package/dist/cjs/lib/installHelpers.d.ts +17 -0
  33. package/dist/cjs/lib/installHelpers.d.ts.map +1 -0
  34. package/dist/cjs/lib/installHelpers.js +72 -0
  35. package/dist/cjs/lib/loadEnvFiles.d.ts +5 -0
  36. package/dist/cjs/lib/loadEnvFiles.d.ts.map +1 -0
  37. package/dist/cjs/lib/loadEnvFiles.js +101 -0
  38. package/dist/cjs/lib/paths.d.ts +6 -0
  39. package/dist/cjs/lib/paths.d.ts.map +1 -0
  40. package/dist/cjs/lib/paths.js +42 -0
  41. package/dist/cjs/lib/project.d.ts +42 -0
  42. package/dist/cjs/lib/project.d.ts.map +1 -0
  43. package/dist/cjs/lib/project.js +265 -0
  44. package/dist/cjs/lib/version.d.ts +17 -0
  45. package/dist/cjs/lib/version.d.ts.map +1 -0
  46. package/dist/cjs/lib/version.js +107 -0
  47. package/dist/cjs/package.json +1 -0
  48. package/dist/cjs/telemetry/index.d.ts +20 -0
  49. package/dist/cjs/telemetry/index.d.ts.map +1 -0
  50. package/dist/cjs/telemetry/index.js +62 -0
  51. package/dist/index.d.ts +12 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +20 -0
  54. package/dist/lib/colors.d.ts +23 -0
  55. package/dist/lib/colors.d.ts.map +1 -0
  56. package/dist/lib/colors.js +18 -0
  57. package/dist/lib/index.d.ts +21 -0
  58. package/dist/lib/index.d.ts.map +1 -0
  59. package/dist/lib/index.js +102 -0
  60. package/dist/lib/installHelpers.d.ts +17 -0
  61. package/dist/lib/installHelpers.d.ts.map +1 -0
  62. package/dist/lib/installHelpers.js +35 -0
  63. package/dist/lib/loadEnvFiles.d.ts +5 -0
  64. package/dist/lib/loadEnvFiles.d.ts.map +1 -0
  65. package/dist/lib/loadEnvFiles.js +64 -0
  66. package/dist/lib/paths.d.ts +6 -0
  67. package/dist/lib/paths.d.ts.map +1 -0
  68. package/dist/lib/paths.js +18 -0
  69. package/dist/lib/project.d.ts +42 -0
  70. package/dist/lib/project.d.ts.map +1 -0
  71. package/dist/lib/project.js +227 -0
  72. package/dist/lib/version.d.ts +17 -0
  73. package/dist/lib/version.d.ts.map +1 -0
  74. package/dist/lib/version.js +73 -0
  75. package/dist/package.json +1 -0
  76. package/dist/src/auth/__tests__/authFiles.test.d.ts +2 -0
  77. package/dist/src/auth/__tests__/authFiles.test.d.ts.map +1 -0
  78. package/dist/src/auth/__tests__/authTasks.test.d.ts +2 -0
  79. package/dist/src/auth/__tests__/authTasks.test.d.ts.map +1 -0
  80. package/dist/src/auth/__tests__/mockFsFiles.d.ts +14 -0
  81. package/dist/src/auth/__tests__/mockFsFiles.d.ts.map +1 -0
  82. package/dist/src/auth/__tests__/setupHelpers.test.d.ts +2 -0
  83. package/dist/src/auth/__tests__/setupHelpers.test.d.ts.map +1 -0
  84. package/dist/src/auth/authFiles.d.ts +44 -0
  85. package/dist/src/auth/authFiles.d.ts.map +1 -0
  86. package/dist/src/auth/authTasks.d.ts +49 -0
  87. package/dist/src/auth/authTasks.d.ts.map +1 -0
  88. package/dist/src/auth/setupHelpers.d.ts +26 -0
  89. package/dist/src/auth/setupHelpers.d.ts.map +1 -0
  90. package/dist/src/index.d.ts +12 -0
  91. package/dist/src/index.d.ts.map +1 -0
  92. package/dist/src/lib/__tests__/index.test.d.ts +2 -0
  93. package/dist/src/lib/__tests__/index.test.d.ts.map +1 -0
  94. package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts +2 -0
  95. package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts.map +1 -0
  96. package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts +2 -0
  97. package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts.map +1 -0
  98. package/dist/src/lib/__tests__/project.test.d.ts +2 -0
  99. package/dist/src/lib/__tests__/project.test.d.ts.map +1 -0
  100. package/dist/src/lib/__tests__/version.test.d.ts +2 -0
  101. package/dist/src/lib/__tests__/version.test.d.ts.map +1 -0
  102. package/dist/src/lib/colors.d.ts +23 -0
  103. package/dist/src/lib/colors.d.ts.map +1 -0
  104. package/dist/src/lib/index.d.ts +21 -0
  105. package/dist/src/lib/index.d.ts.map +1 -0
  106. package/dist/src/lib/installHelpers.d.ts +17 -0
  107. package/dist/src/lib/installHelpers.d.ts.map +1 -0
  108. package/dist/src/lib/loadEnvFiles.d.ts +5 -0
  109. package/dist/src/lib/loadEnvFiles.d.ts.map +1 -0
  110. package/dist/src/lib/paths.d.ts +6 -0
  111. package/dist/src/lib/paths.d.ts.map +1 -0
  112. package/dist/src/lib/project.d.ts +42 -0
  113. package/dist/src/lib/project.d.ts.map +1 -0
  114. package/dist/src/lib/version.d.ts +17 -0
  115. package/dist/src/lib/version.d.ts.map +1 -0
  116. package/dist/src/telemetry/index.d.ts +20 -0
  117. package/dist/src/telemetry/index.d.ts.map +1 -0
  118. package/dist/telemetry/index.d.ts +20 -0
  119. package/dist/telemetry/index.d.ts.map +1 -0
  120. package/dist/telemetry/index.js +27 -0
  121. package/dist/tsconfig.tsbuildinfo +1 -0
  122. package/dist/vitest.config.d.mts +3 -0
  123. package/dist/vitest.config.d.mts.map +1 -0
  124. package/package.json +91 -0
@@ -0,0 +1,52 @@
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 colors_exports = {};
30
+ __export(colors_exports, {
31
+ colors: () => colors
32
+ });
33
+ module.exports = __toCommonJS(colors_exports);
34
+ var import_chalk = __toESM(require("chalk"), 1);
35
+ const colors = {
36
+ error: import_chalk.default.bold.red,
37
+ warning: import_chalk.default.hex("#ffa500"),
38
+ highlight: import_chalk.default.hex("#ffa500"),
39
+ success: import_chalk.default.green,
40
+ info: import_chalk.default.grey,
41
+ bold: import_chalk.default.bold,
42
+ underline: import_chalk.default.underline,
43
+ note: import_chalk.default.blue,
44
+ tip: import_chalk.default.green,
45
+ important: import_chalk.default.magenta,
46
+ caution: import_chalk.default.red,
47
+ link: import_chalk.default.underline
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ colors
52
+ });
@@ -0,0 +1,21 @@
1
+ import type { ListrTaskWrapper, ListrRenderer } from 'listr2';
2
+ import { Listr } from 'listr2';
3
+ export declare const transformTSToJS: (filename: string, content: string) => string | Promise<string>;
4
+ /**
5
+ * This returns the config present in `prettier.config.js` of a Redwood project.
6
+ */
7
+ export declare const getPrettierOptions: () => Promise<any>;
8
+ export declare const prettify: (templateFilename: string, renderedTemplate: string) => Promise<string>;
9
+ export type ExistingFiles = 'OVERWRITE' | 'SKIP' | 'FAIL';
10
+ export declare const writeFile: <Renderer extends typeof ListrRenderer>(target: string, contents: string, { existingFiles }?: {
11
+ existingFiles?: ExistingFiles;
12
+ }, task?: ListrTaskWrapper<never, Renderer, Renderer>) => void;
13
+ /**
14
+ * Creates a list of tasks that write files to the disk.
15
+ *
16
+ * @param files - {[filepath]: contents}
17
+ */
18
+ export declare const writeFilesTask: <Renderer extends typeof ListrRenderer>(files: Record<string, string>, options: {
19
+ existingFiles: ExistingFiles;
20
+ }) => Listr<never, Renderer, "simple">;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAU9B,eAAO,MAAM,eAAe,aAAc,MAAM,WAAW,MAAM,6BA8BhE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAkB9B,CAAA;AAED,eAAO,MAAM,QAAQ,qBACD,MAAM,oBACN,MAAM,KACvB,OAAO,CAAC,MAAM,CAqBhB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,SAAS,OAAO,aAAa,UACrD,MAAM,YACJ,MAAM,sBACY;IAAE,aAAa,CAAC,EAAE,aAAa,CAAA;CAAE,SAGvD,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAwBlD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,OAAO,aAAa,SAC3D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WACpB;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,qCAuB1C,CAAA"}
@@ -0,0 +1,140 @@
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 lib_exports = {};
30
+ __export(lib_exports, {
31
+ getPrettierOptions: () => getPrettierOptions,
32
+ prettify: () => prettify,
33
+ transformTSToJS: () => transformTSToJS,
34
+ writeFile: () => writeFile,
35
+ writeFilesTask: () => writeFilesTask
36
+ });
37
+ module.exports = __toCommonJS(lib_exports);
38
+ var import_fs = __toESM(require("fs"), 1);
39
+ var import_path = __toESM(require("path"), 1);
40
+ var babel = __toESM(require("@babel/core"), 1);
41
+ var import_listr2 = require("listr2");
42
+ var import_prettier = require("prettier");
43
+ var import_colors = require("./colors.js");
44
+ var import_paths = require("./paths.js");
45
+ const transformTSToJS = (filename, content) => {
46
+ if (!content) {
47
+ return content;
48
+ }
49
+ const babelFileResult = babel.transform(content, {
50
+ filename,
51
+ // If you ran `yarn rw generate` in `./web` transformSync would import the `.babelrc.js` file,
52
+ // in `./web`? despite us setting `configFile: false`.
53
+ cwd: process.env.NODE_ENV === "test" ? void 0 : (0, import_paths.getPaths)().base,
54
+ configFile: false,
55
+ plugins: [
56
+ [
57
+ "@babel/plugin-transform-typescript",
58
+ {
59
+ isTSX: true,
60
+ allExtensions: true
61
+ }
62
+ ]
63
+ ],
64
+ retainLines: true
65
+ });
66
+ if (!babelFileResult?.code) {
67
+ console.error(import_colors.colors.error(`Could not transform ${filename} to JS`));
68
+ process.exit(1);
69
+ }
70
+ return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), babelFileResult.code);
71
+ };
72
+ const getPrettierOptions = async () => {
73
+ try {
74
+ const { default: options } = await import(`file://${import_path.default.join((0, import_paths.getPaths)().base, "prettier.config.js")}`);
75
+ if (options.tailwindConfig?.startsWith(".")) {
76
+ options.tailwindConfig = import_path.default.join(
77
+ process.env.RWJS_CWD ?? process.cwd(),
78
+ options.tailwindConfig
79
+ );
80
+ }
81
+ return options;
82
+ } catch {
83
+ return void 0;
84
+ }
85
+ };
86
+ const prettify = async (templateFilename, renderedTemplate) => {
87
+ const parser = {
88
+ ".css": "css",
89
+ ".js": "babel",
90
+ ".ts": "babel-ts",
91
+ ".tsx": "babel-ts"
92
+ }[import_path.default.extname(templateFilename.replace(".template", ""))];
93
+ if (typeof parser === "undefined") {
94
+ return renderedTemplate;
95
+ }
96
+ const prettierOptions = await getPrettierOptions();
97
+ return (0, import_prettier.format)(renderedTemplate, {
98
+ ...prettierOptions,
99
+ parser
100
+ });
101
+ };
102
+ const writeFile = (target, contents, { existingFiles = "FAIL" } = {}, task = {}) => {
103
+ const { base } = (0, import_paths.getPaths)();
104
+ task.title = `Writing \`./${import_path.default.relative(base, target)}\``;
105
+ const exists = import_fs.default.existsSync(target);
106
+ if (exists && existingFiles === "FAIL") {
107
+ throw new Error(`${target} already exists.`);
108
+ }
109
+ if (exists && existingFiles === "SKIP") {
110
+ task.skip(`Skipping update of \`./${import_path.default.relative(base, target)}\``);
111
+ return;
112
+ }
113
+ const filename = import_path.default.basename(target);
114
+ const targetDir = target.replace(filename, "");
115
+ import_fs.default.mkdirSync(targetDir, { recursive: true });
116
+ import_fs.default.writeFileSync(target, contents);
117
+ task.title = `Successfully wrote file \`./${import_path.default.relative(base, target)}\``;
118
+ };
119
+ const writeFilesTask = (files, options) => {
120
+ const { base } = (0, import_paths.getPaths)();
121
+ return new import_listr2.Listr(
122
+ Object.keys(files).map((file) => {
123
+ const contents = files[file];
124
+ return {
125
+ title: `...waiting to write file \`./${import_path.default.relative(base, file)}\`...`,
126
+ task: (_ctx, task) => {
127
+ return writeFile(file, contents, options, task);
128
+ }
129
+ };
130
+ })
131
+ );
132
+ };
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ getPrettierOptions,
136
+ prettify,
137
+ transformTSToJS,
138
+ writeFile,
139
+ writeFilesTask
140
+ });
@@ -0,0 +1,17 @@
1
+ export declare const addWebPackages: (webPackages: string[]) => {
2
+ title: string;
3
+ task: () => Promise<void>;
4
+ };
5
+ export declare const addApiPackages: (apiPackages: string[]) => {
6
+ title: string;
7
+ task: () => Promise<void>;
8
+ };
9
+ export declare const addRootPackages: (packages: string[], devDependency?: boolean) => {
10
+ title: string;
11
+ task: () => Promise<void>;
12
+ };
13
+ export declare const installPackages: {
14
+ title: string;
15
+ task: () => Promise<void>;
16
+ };
17
+ //# sourceMappingURL=installHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installHelpers.d.ts","sourceRoot":"","sources":["../../../src/lib/installHelpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gBAAiB,MAAM,EAAE;;;CAKlD,CAAA;AAEF,eAAO,MAAM,cAAc,gBAAiB,MAAM,EAAE;;;CAKlD,CAAA;AAEF,eAAO,MAAM,eAAe,aAAc,MAAM,EAAE;;;CAQjD,CAAA;AAED,eAAO,MAAM,eAAe;;;CAK3B,CAAA"}
@@ -0,0 +1,72 @@
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 installHelpers_exports = {};
30
+ __export(installHelpers_exports, {
31
+ addApiPackages: () => addApiPackages,
32
+ addRootPackages: () => addRootPackages,
33
+ addWebPackages: () => addWebPackages,
34
+ installPackages: () => installPackages
35
+ });
36
+ module.exports = __toCommonJS(installHelpers_exports);
37
+ var import_execa = __toESM(require("execa"), 1);
38
+ var import_paths = require("./paths.js");
39
+ const addWebPackages = (webPackages) => ({
40
+ title: "Adding required web packages...",
41
+ task: async () => {
42
+ await (0, import_execa.default)("yarn", ["add", ...webPackages], { cwd: (0, import_paths.getPaths)().web.base });
43
+ }
44
+ });
45
+ const addApiPackages = (apiPackages) => ({
46
+ title: "Adding required api packages...",
47
+ task: async () => {
48
+ await (0, import_execa.default)("yarn", ["add", ...apiPackages], { cwd: (0, import_paths.getPaths)().api.base });
49
+ }
50
+ });
51
+ const addRootPackages = (packages, devDependency = false) => {
52
+ const addMode = devDependency ? ["add", "-D"] : ["add"];
53
+ return {
54
+ title: "Installing packages...",
55
+ task: async () => {
56
+ await (0, import_execa.default)("yarn", [...addMode, ...packages], { cwd: (0, import_paths.getPaths)().base });
57
+ }
58
+ };
59
+ };
60
+ const installPackages = {
61
+ title: "Installing packages...",
62
+ task: async () => {
63
+ await (0, import_execa.default)("yarn", ["install"], { cwd: (0, import_paths.getPaths)().base });
64
+ }
65
+ };
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ addApiPackages,
69
+ addRootPackages,
70
+ addWebPackages,
71
+ installPackages
72
+ });
@@ -0,0 +1,5 @@
1
+ export declare function loadEnvFiles(): void;
2
+ export declare function loadDefaultEnvFiles(cwd: string): void;
3
+ export declare function loadNodeEnvDerivedEnvFile(cwd: string): void;
4
+ export declare function loadUserSpecifiedEnvFiles(cwd: string, loadEnvFiles: string[]): void;
5
+ //# sourceMappingURL=loadEnvFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadEnvFiles.d.ts","sourceRoot":"","sources":["../../../src/lib/loadEnvFiles.ts"],"names":[],"mappings":"AAUA,wBAAgB,YAAY,SAsB3B;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,QAQ9C;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,QAcpD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAW5E"}
@@ -0,0 +1,101 @@
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 loadEnvFiles_exports = {};
30
+ __export(loadEnvFiles_exports, {
31
+ loadDefaultEnvFiles: () => loadDefaultEnvFiles,
32
+ loadEnvFiles: () => loadEnvFiles,
33
+ loadNodeEnvDerivedEnvFile: () => loadNodeEnvDerivedEnvFile,
34
+ loadUserSpecifiedEnvFiles: () => loadUserSpecifiedEnvFiles
35
+ });
36
+ module.exports = __toCommonJS(loadEnvFiles_exports);
37
+ var import_node_fs = __toESM(require("node:fs"), 1);
38
+ var import_node_path = __toESM(require("node:path"), 1);
39
+ var import_dotenv = require("dotenv");
40
+ var import_dotenv_defaults = require("dotenv-defaults");
41
+ var import_helpers = require("yargs/helpers");
42
+ var import_yargs_parser = __toESM(require("yargs-parser"), 1);
43
+ var import_project_config = require("@cedarjs/project-config");
44
+ function loadEnvFiles() {
45
+ if (process.env.REDWOOD_ENV_FILES_LOADED) {
46
+ return;
47
+ }
48
+ const { base } = (0, import_project_config.getPaths)();
49
+ loadDefaultEnvFiles(base);
50
+ loadNodeEnvDerivedEnvFile(base);
51
+ const { loadEnvFiles: loadEnvFiles2 } = (0, import_yargs_parser.default)((0, import_helpers.hideBin)(process.argv), {
52
+ array: ["load-env-files"],
53
+ default: {
54
+ loadEnvFiles: []
55
+ }
56
+ });
57
+ if (loadEnvFiles2.length > 0) {
58
+ loadUserSpecifiedEnvFiles(base, loadEnvFiles2);
59
+ }
60
+ process.env.REDWOOD_ENV_FILES_LOADED = "true";
61
+ }
62
+ function loadDefaultEnvFiles(cwd) {
63
+ (0, import_dotenv_defaults.config)({
64
+ path: import_node_path.default.join(cwd, ".env"),
65
+ defaults: import_node_path.default.join(cwd, ".env.defaults"),
66
+ // @ts-expect-error - Old typings. @types/dotenv-defaults depends on dotenv
67
+ // v8. dotenv-defaults uses dotenv v14
68
+ multiline: true
69
+ });
70
+ }
71
+ function loadNodeEnvDerivedEnvFile(cwd) {
72
+ if (!process.env.NODE_ENV) {
73
+ return;
74
+ }
75
+ const nodeEnvDerivedEnvFilePath = import_node_path.default.join(
76
+ cwd,
77
+ `.env.${process.env.NODE_ENV}`
78
+ );
79
+ if (!import_node_fs.default.existsSync(nodeEnvDerivedEnvFilePath)) {
80
+ return;
81
+ }
82
+ (0, import_dotenv.config)({ path: nodeEnvDerivedEnvFilePath, override: true });
83
+ }
84
+ function loadUserSpecifiedEnvFiles(cwd, loadEnvFiles2) {
85
+ for (const suffix of loadEnvFiles2) {
86
+ const envPath = import_node_path.default.join(cwd, `.env.${suffix}`);
87
+ if (!import_node_fs.default.existsSync(envPath)) {
88
+ throw new Error(
89
+ `Couldn't find an .env file at '${envPath}' as specified by '--load-env-files'`
90
+ );
91
+ }
92
+ (0, import_dotenv.config)({ path: envPath, override: true });
93
+ }
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ loadDefaultEnvFiles,
98
+ loadEnvFiles,
99
+ loadNodeEnvDerivedEnvFile,
100
+ loadUserSpecifiedEnvFiles
101
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This wraps the core version of getPaths into something that catches the exception
3
+ * and displays a helpful error message.
4
+ */
5
+ export declare function getPaths(): import("@cedarjs/project-config").Paths;
6
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/lib/paths.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,QAAQ,4CAUvB"}
@@ -0,0 +1,42 @@
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 paths_exports = {};
20
+ __export(paths_exports, {
21
+ getPaths: () => getPaths
22
+ });
23
+ module.exports = __toCommonJS(paths_exports);
24
+ var import_project_config = require("@cedarjs/project-config");
25
+ var import_colors = require("./colors.js");
26
+ function isErrorWithMessage(e) {
27
+ return !!e.message;
28
+ }
29
+ function getPaths() {
30
+ try {
31
+ return (0, import_project_config.getPaths)();
32
+ } catch (e) {
33
+ if (isErrorWithMessage(e)) {
34
+ console.error(import_colors.colors.error(e.message));
35
+ }
36
+ process.exit(1);
37
+ }
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getPaths
42
+ });
@@ -0,0 +1,42 @@
1
+ import type { Config } from '@cedarjs/project-config';
2
+ export declare const getGraphqlPath: () => string | null;
3
+ export declare const graphFunctionDoesExist: () => boolean | "" | null;
4
+ export declare const isTypeScriptProject: () => boolean;
5
+ export declare const getInstalledRedwoodVersion: () => any;
6
+ /**
7
+ * Updates the project's redwood.toml file to include the specified packages plugin
8
+ *
9
+ * Uses toml parsing to determine if the plugin is already included in the file and
10
+ * only adds it if it is not.
11
+ *
12
+ * Writes the updated config to the file system by appending strings, not stringify-ing the toml.
13
+ */
14
+ export declare const updateTomlConfig: (packageName: string) => void;
15
+ export declare const updateTomlConfigTask: (packageName: string) => {
16
+ title: string;
17
+ task: () => void;
18
+ };
19
+ export declare const addEnvVarTask: (name: string, value: string, comment: string) => {
20
+ title: string;
21
+ task: () => void;
22
+ };
23
+ export declare const addEnvVar: (name: string, value: string, comment: string) => string | void;
24
+ /**
25
+ * This sets the `RWJS_CWD` env var to the redwood project directory. This is typically required for internal
26
+ * redwood packages to work correctly. For example, `@cedarjs/project-config` uses this when reading config
27
+ * or paths.
28
+ *
29
+ * @param cwd Explicitly set the redwood cwd. If not set, we'll try to determine it automatically. You likely
30
+ * only want to set this based on some specific input, like a CLI flag.
31
+ */
32
+ export declare const setRedwoodCWD: (cwd?: string) => void;
33
+ /**
34
+ * Create or update the given setting, in the given section, with the given value.
35
+ *
36
+ * If the section already exists it adds the new setting last
37
+ * If the section, and the setting, already exists, the setting is updated
38
+ * If the section does not exist it is created at the end of the file and the setting is added
39
+ * If the setting exists in the section, but is commented out, it will be uncommented and updated
40
+ */
41
+ export declare function setTomlSetting(section: keyof Config, setting: string, value: string | boolean | number): void;
42
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/lib/project.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAWrD,eAAO,MAAM,cAAc,qBAE1B,CAAA;AAED,eAAO,MAAM,sBAAsB,2BAGlC,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,0BAA0B,WAQtC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,SAmDnD,CAAA;AAED,eAAO,MAAM,oBAAoB,gBAAiB,MAAM;;;CAOvD,CAAA;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,SAAS,MAAM,WAAW,MAAM;;;CAOzE,CAAA;AAED,eAAO,MAAM,SAAS,SAAU,MAAM,SAAS,MAAM,WAAW,MAAM,kBAqCrE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,SAyBzC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,QA0HjC"}