@cedarjs/cli-helpers 7.0.0 → 7.0.1-next.307
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/authFiles.d.ts +9 -1
- package/dist/auth/authFiles.d.ts.map +1 -1
- package/dist/auth/authFiles.js +44 -22
- package/dist/auth/authTasks.d.ts +1 -1
- package/dist/auth/authTasks.d.ts.map +1 -1
- package/dist/auth/authTasks.js +2 -2
- package/dist/auth/setupHelpers.d.ts +2 -1
- package/dist/auth/setupHelpers.d.ts.map +1 -1
- package/dist/auth/setupHelpers.js +2 -1
- package/dist/lib/colors.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +7 -21
- package/dist/lib/transpileTSToJS.d.ts +18 -0
- package/dist/lib/transpileTSToJS.d.ts.map +1 -0
- package/dist/lib/transpileTSToJS.js +38 -0
- package/dist/lib/tty.d.ts +11 -0
- package/dist/lib/tty.d.ts.map +1 -0
- package/dist/lib/tty.js +16 -0
- package/dist/lib/version.js +5 -5
- package/package.json +68 -16
- package/dist/index.d.ts +0 -12
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -20
package/dist/auth/authFiles.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
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;
|
|
4
12
|
}
|
|
5
13
|
/**
|
|
6
14
|
* Get the api side file paths and file contents to write
|
|
@@ -14,7 +22,7 @@ interface FilesArgs {
|
|
|
14
22
|
* }
|
|
15
23
|
* ```
|
|
16
24
|
*/
|
|
17
|
-
export declare const apiSideFiles: ({ basedir, webAuthn }: FilesArgs) => Promise<Record<string, string>>;
|
|
25
|
+
export declare const apiSideFiles: ({ basedir, webAuthn, oauth, }: FilesArgs) => Promise<Record<string, string>>;
|
|
18
26
|
/**
|
|
19
27
|
* Loops through the keys in `filesRecord` and generates unique file paths if
|
|
20
28
|
* 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;
|
|
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"}
|
package/dist/auth/authFiles.js
CHANGED
|
@@ -4,37 +4,59 @@ 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
|
|
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
|
+
}) => {
|
|
8
41
|
const apiSrcPath = getPaths().api.src;
|
|
9
42
|
const apiBaseTemplatePath = path.join(basedir, "templates", "api");
|
|
10
43
|
const templateDirectories = fs.readdirSync(apiBaseTemplatePath);
|
|
11
44
|
let filesRecord = {};
|
|
45
|
+
const activeTags = [
|
|
46
|
+
...webAuthn ? ["webAuthn"] : [],
|
|
47
|
+
...oauth ? ["oauth"] : []
|
|
48
|
+
];
|
|
12
49
|
for (const dir of templateDirectories) {
|
|
13
50
|
const templateFiles = fs.readdirSync(path.join(apiBaseTemplatePath, dir));
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let outputFileName = fileName.replace(/\.template$/, "");
|
|
51
|
+
const pickedVariants = pickTemplateVariants(templateFiles, activeTags);
|
|
52
|
+
const filePaths = pickedVariants.map(({ fileName }) => {
|
|
53
|
+
const { baseName, ext } = parseTemplateFileName(fileName);
|
|
54
|
+
let outputFileName = `${baseName}.${ext}`;
|
|
19
55
|
if (!isTypeScriptProject()) {
|
|
20
56
|
outputFileName = outputFileName.replace(/\.ts(x?)$/, ".js$1");
|
|
21
57
|
}
|
|
22
|
-
|
|
23
|
-
|
|
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);
|
|
58
|
+
const templateFilePath = path.join(apiBaseTemplatePath, dir, fileName);
|
|
59
|
+
const outputFilePath = path.join(apiSrcPath, dir, outputFileName);
|
|
38
60
|
return { templateFilePath, outputFilePath };
|
|
39
61
|
});
|
|
40
62
|
for (const paths of filePaths) {
|
package/dist/auth/authTasks.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare const addConfigToRoutes: () => {
|
|
|
31
31
|
*
|
|
32
32
|
* @returns Listr task
|
|
33
33
|
*/
|
|
34
|
-
export declare const generateAuthApiFiles: <Renderer extends typeof ListrRenderer>(basedir: string, webAuthn: boolean) => ListrTask<AuthGeneratorCtx, Renderer>;
|
|
34
|
+
export declare const generateAuthApiFiles: <Renderer extends typeof ListrRenderer>(basedir: string, webAuthn: boolean, oauth?: boolean) => ListrTask<AuthGeneratorCtx, Renderer>;
|
|
35
35
|
export declare const addAuthConfigToGqlApi: <Renderer extends typeof ListrRenderer, FallbackRenderer extends typeof ListrRenderer>(authDecoderImport?: string) => {
|
|
36
36
|
title: string;
|
|
37
37
|
task: (ctx: AuthGeneratorCtx, _task: ListrTaskWrapper<AuthGeneratorCtx, Renderer, FallbackRenderer>) => void;
|
|
@@ -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;AA2BxE,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,OAAO;;gBAgC1C,gBAAgB;CA0CrC,CAAA;AAED,eAAO,MAAM,iBAAiB;;;CAmB7B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,OAAO,aAAa,EACxE,SAAS,MAAM,EACf,UAAU,OAAO,
|
|
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;AA2BxE,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,OAAO;;gBAgC1C,gBAAgB;CA0CrC,CAAA;AAED,eAAO,MAAM,iBAAiB;;;CAmB7B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,OAAO,aAAa,EACxE,SAAS,MAAM,EACf,UAAU,OAAO,EACjB,eAAa,KACZ,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CAgDtC,CAAA;AASD,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,OAAO,aAAa,EACrC,gBAAgB,SAAS,OAAO,aAAa,EAE7C,oBAAoB,MAAM;;gBAInB,gBAAgB,SACd,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CAcvE,CAAA;AAEF,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,CAAA;AAEb,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,SAAS,OAAO,aAAa,EACrC,gBAAgB,SAAS,OAAO,aAAa,EAE7C,OAAO,OAAO;;gBAKL,gBAAgB,QACf,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CA2CzE,CAAA"}
|
package/dist/auth/authTasks.js
CHANGED
|
@@ -264,7 +264,7 @@ const addConfigToRoutes = () => {
|
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
266
|
};
|
|
267
|
-
const generateAuthApiFiles = (basedir, webAuthn) => {
|
|
267
|
+
const generateAuthApiFiles = (basedir, webAuthn, oauth = false) => {
|
|
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) => {
|
|
|
273
273
|
"Could not find api/src directory. Cannot continue setup!"
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
let filesRecord = await apiSideFiles({ basedir, webAuthn });
|
|
276
|
+
let filesRecord = await apiSideFiles({ basedir, webAuthn, oauth });
|
|
277
277
|
let existingFiles = "FAIL";
|
|
278
278
|
if (ctx.setupMode === "FORCE") {
|
|
279
279
|
existingFiles = "OVERWRITE";
|
|
@@ -13,6 +13,7 @@ export interface AuthHandlerArgs {
|
|
|
13
13
|
provider: string;
|
|
14
14
|
authDecoderImport?: string;
|
|
15
15
|
webAuthn?: boolean;
|
|
16
|
+
oauth?: boolean;
|
|
16
17
|
webPackages?: string[];
|
|
17
18
|
apiPackages?: string[];
|
|
18
19
|
extraTasks?: (ListrTask<AuthGeneratorCtx> | undefined)[];
|
|
@@ -23,5 +24,5 @@ export interface AuthHandlerArgs {
|
|
|
23
24
|
* basedir assumes that you must have a templates folder in that directory.
|
|
24
25
|
* See folder structure of auth providers in packages/auth-providers/<provider>/setup/src
|
|
25
26
|
*/
|
|
26
|
-
export declare const standardAuthHandler: ({ basedir, forceArg, provider, authDecoderImport, webAuthn, webPackages, apiPackages, extraTasks, notes, verbose, }: AuthHandlerArgs) => Promise<void>;
|
|
27
|
+
export declare const standardAuthHandler: ({ basedir, forceArg, provider, authDecoderImport, webAuthn, oauth, webPackages, apiPackages, extraTasks, notes, verbose, }: AuthHandlerArgs) => Promise<void>;
|
|
27
28
|
//# 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,EAAE,MAAM,QAAQ,CAAA;AAGvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAWjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC,eAAO,MAAM,mBAAmB,GAAI,OAAO,IAAI;;;;EAoB9C,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,EAAE,CAAA;IACxD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AASD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAU,
|
|
1
|
+
{"version":3,"file":"setupHelpers.d.ts","sourceRoot":"","sources":["../../src/auth/setupHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAWjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,YAAY,EAAE,gBAAgB,EAAE,CAAA;AAEhC,eAAO,MAAM,mBAAmB,GAAI,OAAO,IAAI;;;;EAoB9C,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,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,4HAYvC,eAAe,kBAiFjB,CAAA"}
|
|
@@ -42,6 +42,7 @@ const standardAuthHandler = async ({
|
|
|
42
42
|
provider,
|
|
43
43
|
authDecoderImport,
|
|
44
44
|
webAuthn = false,
|
|
45
|
+
oauth = false,
|
|
45
46
|
webPackages = [],
|
|
46
47
|
apiPackages = [],
|
|
47
48
|
extraTasks,
|
|
@@ -51,7 +52,7 @@ const standardAuthHandler = async ({
|
|
|
51
52
|
const tasks = new Listr(
|
|
52
53
|
[
|
|
53
54
|
setAuthSetupMode(forceArg),
|
|
54
|
-
generateAuthApiFiles(basedir, webAuthn),
|
|
55
|
+
generateAuthApiFiles(basedir, webAuthn, oauth),
|
|
55
56
|
addConfigToWebApp(),
|
|
56
57
|
createWebAuth(basedir, webAuthn),
|
|
57
58
|
addConfigToRoutes(),
|
package/dist/lib/colors.d.ts
CHANGED
|
@@ -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'
|
|
5
|
+
* import { colors } from '@cedarjs/cli-helpers/colors'
|
|
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.
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1,37 +1,23 @@
|
|
|
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";
|
|
5
4
|
import { Listr } from "listr2";
|
|
6
5
|
import { format } from "prettier";
|
|
7
6
|
import { colors } from "./colors.js";
|
|
8
7
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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`));
|
|
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)));
|
|
32
18
|
process.exit(1);
|
|
33
19
|
}
|
|
34
|
-
return prettify(filename.replace(/\.ts(x)?$/, ".js$1"),
|
|
20
|
+
return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), code);
|
|
35
21
|
};
|
|
36
22
|
const getPrettierOptions = async () => {
|
|
37
23
|
try {
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
package/dist/lib/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import
|
|
3
|
+
import { rangesIntersect, sort, tryParse } from "verkit";
|
|
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 =
|
|
15
|
+
const semverVersion = tryParse(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 &&
|
|
37
|
+
if (packageRedwoodSpecification !== void 0 && rangesIntersect(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 =
|
|
50
|
+
const versions = 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 (
|
|
56
|
+
if (rangesIntersect(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.
|
|
3
|
+
"version": "7.0.1-next.307",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -9,12 +9,6 @@
|
|
|
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
|
-
},
|
|
18
12
|
"./loadEnvFiles": {
|
|
19
13
|
"default": {
|
|
20
14
|
"types": "./dist/lib/loadEnvFiles.d.ts",
|
|
@@ -56,9 +50,68 @@
|
|
|
56
50
|
"types": "./dist/packageManager/workspaces.d.ts",
|
|
57
51
|
"default": "./dist/packageManager/workspaces.js"
|
|
58
52
|
}
|
|
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
|
+
}
|
|
59
113
|
}
|
|
60
114
|
},
|
|
61
|
-
"types": "./dist/index.d.ts",
|
|
62
115
|
"files": [
|
|
63
116
|
"dist"
|
|
64
117
|
],
|
|
@@ -72,9 +125,8 @@
|
|
|
72
125
|
"test:watch": "vitest watch"
|
|
73
126
|
},
|
|
74
127
|
"dependencies": {
|
|
75
|
-
"@
|
|
76
|
-
"@cedarjs/
|
|
77
|
-
"@cedarjs/telemetry": "7.0.0",
|
|
128
|
+
"@cedarjs/project-config": "7.0.1-next.307",
|
|
129
|
+
"@cedarjs/telemetry": "7.0.1-next.307",
|
|
78
130
|
"@listr2/prompt-adapter-enquirer": "4.3.2",
|
|
79
131
|
"@opentelemetry/api": "1.9.1",
|
|
80
132
|
"ansis": "4.4.0",
|
|
@@ -85,19 +137,19 @@
|
|
|
85
137
|
"listr2": "10.2.2",
|
|
86
138
|
"lodash": "4.18.1",
|
|
87
139
|
"pascalcase": "1.0.0",
|
|
88
|
-
"prettier": "3.9.
|
|
140
|
+
"prettier": "3.9.9",
|
|
89
141
|
"prompts": "2.4.2",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
142
|
+
"smol-toml": "1.9.0",
|
|
143
|
+
"sucrase": "3.35.1",
|
|
92
144
|
"termi-link": "1.1.0",
|
|
145
|
+
"verkit": "0.5.0",
|
|
93
146
|
"yargs-parser": "21.1.1"
|
|
94
147
|
},
|
|
95
148
|
"devDependencies": {
|
|
96
|
-
"@cedarjs/framework-tools": "7.0.
|
|
149
|
+
"@cedarjs/framework-tools": "7.0.1-next.307",
|
|
97
150
|
"@types/dotenv-defaults": "^5.0.0",
|
|
98
151
|
"@types/lodash": "4.17.25",
|
|
99
152
|
"@types/pascalcase": "1.0.3",
|
|
100
|
-
"@types/semver": "^7",
|
|
101
153
|
"@types/yargs": "17.0.35",
|
|
102
154
|
"@types/yargs-parser": "21.0.3",
|
|
103
155
|
"prettier-plugin-tailwindcss": "0.8.1",
|
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './lib/index.js';
|
|
2
|
-
export * from './lib/colors.js';
|
|
3
|
-
export { loadEnvFiles } from './lib/loadEnvFiles.js';
|
|
4
|
-
export { loadDefaultEnvFiles, loadNodeEnvDerivedEnvFile, loadUserSpecifiedEnvFiles, } from './lib/loadEnvFiles.js';
|
|
5
|
-
export * from './lib/paths.js';
|
|
6
|
-
export * from './lib/project.js';
|
|
7
|
-
export * from './lib/version.js';
|
|
8
|
-
export * from './auth/setupHelpers.js';
|
|
9
|
-
export type { AuthHandlerArgs, AuthGeneratorCtx } from './auth/setupHelpers.js';
|
|
10
|
-
export * from './lib/installHelpers.js';
|
|
11
|
-
export * from './telemetry/index.js';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE/E,cAAc,yBAAyB,CAAA;AAEvC,cAAc,sBAAsB,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|