@cedarjs/cli-helpers 5.0.4-next.167 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/authTasks.d.ts.map +1 -1
- package/dist/auth/authTasks.js +4 -11
- package/dist/cjs/auth/authFiles.d.ts +44 -0
- package/dist/cjs/auth/authFiles.d.ts.map +1 -0
- package/dist/cjs/auth/authFiles.js +109 -0
- package/dist/cjs/auth/authTasks.d.ts +49 -0
- package/dist/cjs/auth/authTasks.d.ts.map +1 -0
- package/dist/cjs/auth/authTasks.js +384 -0
- package/dist/cjs/auth/setupHelpers.d.ts +27 -0
- package/dist/cjs/auth/setupHelpers.d.ts.map +1 -0
- package/dist/cjs/auth/setupHelpers.js +141 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/lib/colors.d.ts +24 -0
- package/dist/cjs/lib/colors.d.ts.map +1 -0
- package/dist/cjs/lib/colors.js +52 -0
- package/dist/cjs/lib/index.d.ts +22 -0
- package/dist/cjs/lib/index.d.ts.map +1 -0
- package/dist/cjs/lib/index.js +147 -0
- package/dist/cjs/lib/installHelpers.d.ts +17 -0
- package/dist/cjs/lib/installHelpers.d.ts.map +1 -0
- package/dist/cjs/lib/installHelpers.js +65 -0
- package/dist/cjs/lib/loadEnvFiles.d.ts +5 -0
- package/dist/cjs/lib/loadEnvFiles.d.ts.map +1 -0
- package/dist/cjs/lib/loadEnvFiles.js +99 -0
- package/dist/cjs/lib/paths.d.ts +6 -0
- package/dist/cjs/lib/paths.d.ts.map +1 -0
- package/dist/cjs/lib/paths.js +42 -0
- package/dist/cjs/lib/project.d.ts +44 -0
- package/dist/cjs/lib/project.d.ts.map +1 -0
- package/dist/cjs/lib/project.js +268 -0
- package/dist/cjs/lib/version.d.ts +17 -0
- package/dist/cjs/lib/version.d.ts.map +1 -0
- package/dist/cjs/lib/version.js +107 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/packageManager/display.d.ts +90 -0
- package/dist/cjs/packageManager/display.d.ts.map +1 -0
- package/dist/cjs/packageManager/display.js +139 -0
- package/dist/cjs/packageManager/exec.d.ts +77 -0
- package/dist/cjs/packageManager/exec.d.ts.map +1 -0
- package/dist/cjs/packageManager/exec.js +152 -0
- package/dist/cjs/packageManager/index.d.ts +13 -0
- package/dist/cjs/packageManager/index.d.ts.map +1 -0
- package/dist/cjs/packageManager/index.js +73 -0
- package/dist/cjs/packageManager/packages.d.ts +39 -0
- package/dist/cjs/packageManager/packages.d.ts.map +1 -0
- package/dist/cjs/packageManager/packages.js +91 -0
- package/dist/cjs/packageManager/workspaces.d.ts +4 -0
- package/dist/cjs/packageManager/workspaces.d.ts.map +1 -0
- package/dist/cjs/packageManager/workspaces.js +93 -0
- package/dist/cjs/telemetry/index.d.ts +20 -0
- package/dist/cjs/telemetry/index.d.ts.map +1 -0
- package/dist/cjs/telemetry/index.js +64 -0
- package/dist/lib/project.d.ts.map +1 -1
- package/dist/lib/project.js +1 -2
- package/dist/package.json +1 -0
- package/package.json +50 -18
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
});
|
|
@@ -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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/lib/colors.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAalB,CAAA"}
|
|
@@ -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_ansis = __toESM(require("ansis"), 1);
|
|
35
|
+
const colors = {
|
|
36
|
+
error: import_ansis.default.bold.red,
|
|
37
|
+
warning: import_ansis.default.hex("#ffa500"),
|
|
38
|
+
highlight: import_ansis.default.hex("#ffa500"),
|
|
39
|
+
success: import_ansis.default.green,
|
|
40
|
+
info: import_ansis.default.gray,
|
|
41
|
+
bold: import_ansis.default.bold,
|
|
42
|
+
underline: import_ansis.default.underline,
|
|
43
|
+
note: import_ansis.default.blue,
|
|
44
|
+
tip: import_ansis.default.green,
|
|
45
|
+
important: import_ansis.default.magenta,
|
|
46
|
+
caution: import_ansis.default.red,
|
|
47
|
+
link: import_ansis.default.underline
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
colors
|
|
52
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
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.cjs` or
|
|
6
|
+
* `prettier.config.mjs` of a Cedar project.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPrettierOptions: () => Promise<any>;
|
|
9
|
+
export declare const prettify: (templateFilename: string, renderedTemplate: string) => Promise<string>;
|
|
10
|
+
export type ExistingFiles = 'OVERWRITE' | 'SKIP' | 'FAIL';
|
|
11
|
+
export declare const writeFile: <Renderer extends typeof ListrRenderer>(target: string, contents: string, { existingFiles }?: {
|
|
12
|
+
existingFiles?: ExistingFiles;
|
|
13
|
+
}, task?: ListrTaskWrapper<never, Renderer, Renderer>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a list of tasks that write files to the disk.
|
|
16
|
+
*
|
|
17
|
+
* @param files - {[filepath]: contents}
|
|
18
|
+
*/
|
|
19
|
+
export declare const writeFilesTask: <Renderer extends typeof ListrRenderer>(files: Record<string, string>, options: {
|
|
20
|
+
existingFiles: ExistingFiles;
|
|
21
|
+
}) => Listr<never, Renderer, Renderer>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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_node_fs = __toESM(require("node:fs"), 1);
|
|
39
|
+
var import_node_url = require("node:url");
|
|
40
|
+
var import_path = __toESM(require("path"), 1);
|
|
41
|
+
var babel = __toESM(require("@babel/core"), 1);
|
|
42
|
+
var import_listr2 = require("listr2");
|
|
43
|
+
var import_prettier = require("prettier");
|
|
44
|
+
var import_colors = require("./colors.js");
|
|
45
|
+
var import_paths = require("./paths.js");
|
|
46
|
+
const transformTSToJS = (filename, content) => {
|
|
47
|
+
if (!content) {
|
|
48
|
+
return content;
|
|
49
|
+
}
|
|
50
|
+
const babelFileResult = babel.transform(content, {
|
|
51
|
+
filename,
|
|
52
|
+
// If you ran `yarn cedar generate` in `./web` transformSync would import the `.babelrc.js` file,
|
|
53
|
+
// in `./web`? despite us setting `configFile: false`.
|
|
54
|
+
cwd: process.env.NODE_ENV === "test" ? void 0 : (0, import_paths.getPaths)().base,
|
|
55
|
+
configFile: false,
|
|
56
|
+
plugins: [
|
|
57
|
+
[
|
|
58
|
+
"@babel/plugin-transform-typescript",
|
|
59
|
+
{
|
|
60
|
+
isTSX: true,
|
|
61
|
+
allExtensions: true
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
],
|
|
65
|
+
retainLines: true
|
|
66
|
+
});
|
|
67
|
+
if (!babelFileResult?.code) {
|
|
68
|
+
console.error(import_colors.colors.error(`Could not transform ${filename} to JS`));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), babelFileResult.code);
|
|
72
|
+
};
|
|
73
|
+
const getPrettierOptions = async () => {
|
|
74
|
+
try {
|
|
75
|
+
const cjsPath = import_path.default.join((0, import_paths.getPaths)().base, "prettier.config.cjs");
|
|
76
|
+
const mjsPath = import_path.default.join((0, import_paths.getPaths)().base, "prettier.config.mjs");
|
|
77
|
+
const prettierConfigPath = import_node_fs.default.existsSync(cjsPath) ? cjsPath : mjsPath;
|
|
78
|
+
const { default: options } = await import((0, import_node_url.pathToFileURL)(prettierConfigPath).href);
|
|
79
|
+
if (options.tailwindConfig?.startsWith(".")) {
|
|
80
|
+
options.tailwindConfig = import_path.default.join(
|
|
81
|
+
process.env.CEDAR_CWD ?? process.env.RWJS_CWD ?? process.cwd(),
|
|
82
|
+
options.tailwindConfig
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return options;
|
|
86
|
+
} catch {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const prettify = async (templateFilename, renderedTemplate) => {
|
|
91
|
+
const parser = {
|
|
92
|
+
".css": "css",
|
|
93
|
+
".js": "babel",
|
|
94
|
+
".cjs": "babel",
|
|
95
|
+
".mjs": "babel",
|
|
96
|
+
".ts": "babel-ts",
|
|
97
|
+
".mts": "babel-ts",
|
|
98
|
+
".tsx": "babel-ts"
|
|
99
|
+
}[import_path.default.extname(templateFilename.replace(".template", ""))];
|
|
100
|
+
if (typeof parser === "undefined") {
|
|
101
|
+
return renderedTemplate;
|
|
102
|
+
}
|
|
103
|
+
const prettierOptions = await getPrettierOptions();
|
|
104
|
+
return (0, import_prettier.format)(renderedTemplate, {
|
|
105
|
+
...prettierOptions,
|
|
106
|
+
parser
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const writeFile = (target, contents, { existingFiles = "FAIL" } = {}, task = {}) => {
|
|
110
|
+
const { base } = (0, import_paths.getPaths)();
|
|
111
|
+
task.title = `Writing \`./${import_path.default.relative(base, target)}\``;
|
|
112
|
+
const exists = import_node_fs.default.existsSync(target);
|
|
113
|
+
if (exists && existingFiles === "FAIL") {
|
|
114
|
+
throw new Error(`${target} already exists.`);
|
|
115
|
+
}
|
|
116
|
+
if (exists && existingFiles === "SKIP") {
|
|
117
|
+
task.skip(`Skipping update of \`./${import_path.default.relative(base, target)}\``);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const filename = import_path.default.basename(target);
|
|
121
|
+
const targetDir = target.replace(filename, "");
|
|
122
|
+
import_node_fs.default.mkdirSync(targetDir, { recursive: true });
|
|
123
|
+
import_node_fs.default.writeFileSync(target, contents);
|
|
124
|
+
task.title = `Successfully wrote file \`./${import_path.default.relative(base, target)}\``;
|
|
125
|
+
};
|
|
126
|
+
const writeFilesTask = (files, options) => {
|
|
127
|
+
const { base } = (0, import_paths.getPaths)();
|
|
128
|
+
return new import_listr2.Listr(
|
|
129
|
+
Object.keys(files).map((file) => {
|
|
130
|
+
const contents = files[file];
|
|
131
|
+
return {
|
|
132
|
+
title: `...waiting to write file \`./${import_path.default.relative(base, file)}\`...`,
|
|
133
|
+
task: (_ctx, task) => {
|
|
134
|
+
return writeFile(file, contents, options, task);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
getPrettierOptions,
|
|
143
|
+
prettify,
|
|
144
|
+
transformTSToJS,
|
|
145
|
+
writeFile,
|
|
146
|
+
writeFilesTask
|
|
147
|
+
});
|
|
@@ -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":"AAQA,eAAO,MAAM,cAAc,GAAI,aAAa,MAAM,EAAE;;;CAMlD,CAAA;AAEF,eAAO,MAAM,cAAc,GAAI,aAAa,MAAM,EAAE;;;CAMlD,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,EAAE,uBAAqB;;;CAQxE,CAAA;AAED,eAAO,MAAM,eAAe;;;CAM3B,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 installHelpers_exports = {};
|
|
20
|
+
__export(installHelpers_exports, {
|
|
21
|
+
addApiPackages: () => addApiPackages,
|
|
22
|
+
addRootPackages: () => addRootPackages,
|
|
23
|
+
addWebPackages: () => addWebPackages,
|
|
24
|
+
installPackages: () => installPackages
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(installHelpers_exports);
|
|
27
|
+
var import_packages = require("../packageManager/packages.js");
|
|
28
|
+
var import_paths = require("./paths.js");
|
|
29
|
+
const addWebPackages = (webPackages) => ({
|
|
30
|
+
title: `Adding required web packages...`,
|
|
31
|
+
task: async () => {
|
|
32
|
+
const cwd = (0, import_paths.getPaths)().web.base;
|
|
33
|
+
await (0, import_packages.addWorkspacePackages)("web", webPackages, { cwd });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const addApiPackages = (apiPackages) => ({
|
|
37
|
+
title: "Adding required api packages...",
|
|
38
|
+
task: async () => {
|
|
39
|
+
const cwd = (0, import_paths.getPaths)().api.base;
|
|
40
|
+
await (0, import_packages.addWorkspacePackages)("api", apiPackages, { cwd });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const addRootPackages = (packages, devDependency = false) => {
|
|
44
|
+
return {
|
|
45
|
+
title: "Installing packages...",
|
|
46
|
+
task: async () => {
|
|
47
|
+
const cwd = (0, import_paths.getPaths)().base;
|
|
48
|
+
await (0, import_packages.addRootPackages)(packages, { cwd, dev: devDependency });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const installPackages = {
|
|
53
|
+
title: "Installing packages...",
|
|
54
|
+
task: async () => {
|
|
55
|
+
const cwd = (0, import_paths.getPaths)().base;
|
|
56
|
+
await (0, import_packages.installPackages)({ cwd });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
addApiPackages,
|
|
62
|
+
addRootPackages,
|
|
63
|
+
addWebPackages,
|
|
64
|
+
installPackages
|
|
65
|
+
});
|
|
@@ -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,QAM9C;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,QAcpD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAW5E"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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.CEDAR_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.CEDAR_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
|
+
multiline: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function loadNodeEnvDerivedEnvFile(cwd) {
|
|
70
|
+
if (!process.env.NODE_ENV) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const nodeEnvDerivedEnvFilePath = import_node_path.default.join(
|
|
74
|
+
cwd,
|
|
75
|
+
`.env.${process.env.NODE_ENV}`
|
|
76
|
+
);
|
|
77
|
+
if (!import_node_fs.default.existsSync(nodeEnvDerivedEnvFilePath)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
(0, import_dotenv.config)({ path: nodeEnvDerivedEnvFilePath, override: true });
|
|
81
|
+
}
|
|
82
|
+
function loadUserSpecifiedEnvFiles(cwd, loadEnvFiles2) {
|
|
83
|
+
for (const suffix of loadEnvFiles2) {
|
|
84
|
+
const envPath = import_node_path.default.join(cwd, `.env.${suffix}`);
|
|
85
|
+
if (!import_node_fs.default.existsSync(envPath)) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Couldn't find an .env file at '${envPath}' as specified by '--load-env-files'`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
(0, import_dotenv.config)({ path: envPath, override: true });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
loadDefaultEnvFiles,
|
|
96
|
+
loadEnvFiles,
|
|
97
|
+
loadNodeEnvDerivedEnvFile,
|
|
98
|
+
loadUserSpecifiedEnvFiles
|
|
99
|
+
});
|