@cedarjs/internal 7.0.0-canary.3001 → 7.0.0-canary.3004
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/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/package.json +10 -17
- package/dist/ts2js.d.ts +0 -40
- package/dist/ts2js.d.ts.map +0 -1
- package/dist/ts2js.js +0 -119
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,cAAc,qBAAqB,CAAA;AAGnC,cAAc,uBAAuB,CAAA;AAErC,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.3004",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -52,12 +52,6 @@
|
|
|
52
52
|
"default": "./dist/routes.js"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"./dist/ts2js": {
|
|
56
|
-
"default": {
|
|
57
|
-
"types": "./dist/ts2js.d.ts",
|
|
58
|
-
"default": "./dist/ts2js.js"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
55
|
"./dist/validateSchema": {
|
|
62
56
|
"default": {
|
|
63
57
|
"types": "./dist/validateSchema.d.ts",
|
|
@@ -119,16 +113,15 @@
|
|
|
119
113
|
"dependencies": {
|
|
120
114
|
"@babel/core": "^7.26.10",
|
|
121
115
|
"@babel/parser": "7.29.8",
|
|
122
|
-
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
123
116
|
"@babel/traverse": "7.29.8",
|
|
124
|
-
"@cedarjs/api": "7.0.0-canary.
|
|
125
|
-
"@cedarjs/babel-config": "7.0.0-canary.
|
|
126
|
-
"@cedarjs/cli-helpers": "7.0.0-canary.
|
|
127
|
-
"@cedarjs/graphql-server": "7.0.0-canary.
|
|
128
|
-
"@cedarjs/project-config": "7.0.0-canary.
|
|
129
|
-
"@cedarjs/router": "7.0.0-canary.
|
|
130
|
-
"@cedarjs/structure": "7.0.0-canary.
|
|
131
|
-
"@cedarjs/utils": "7.0.0-canary.
|
|
117
|
+
"@cedarjs/api": "7.0.0-canary.3004",
|
|
118
|
+
"@cedarjs/babel-config": "7.0.0-canary.3004",
|
|
119
|
+
"@cedarjs/cli-helpers": "7.0.0-canary.3004",
|
|
120
|
+
"@cedarjs/graphql-server": "7.0.0-canary.3004",
|
|
121
|
+
"@cedarjs/project-config": "7.0.0-canary.3004",
|
|
122
|
+
"@cedarjs/router": "7.0.0-canary.3004",
|
|
123
|
+
"@cedarjs/structure": "7.0.0-canary.3004",
|
|
124
|
+
"@cedarjs/utils": "7.0.0-canary.3004",
|
|
132
125
|
"@graphql-codegen/add": "6.0.1",
|
|
133
126
|
"@graphql-codegen/cli": "6.3.1",
|
|
134
127
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
@@ -166,7 +159,7 @@
|
|
|
166
159
|
"vite-tsconfig-paths": "^6.1.1"
|
|
167
160
|
},
|
|
168
161
|
"devDependencies": {
|
|
169
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
162
|
+
"@cedarjs/framework-tools": "7.0.0-canary.3004",
|
|
170
163
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
171
164
|
"@oxc-project/types": "^0.144.0",
|
|
172
165
|
"concurrently": "9.2.4",
|
package/dist/ts2js.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts all the TypeScript files in the `api` and `web` sides to JavaScript.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} cwd - The base path to the project.
|
|
5
|
-
*/
|
|
6
|
-
export declare const convertTsProjectToJs: (cwd?: string) => void;
|
|
7
|
-
/**
|
|
8
|
-
* Converts all the TypeScript files in the `api` and `web` sides to JavaScript.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} cwd - The base path to the project.
|
|
11
|
-
*/
|
|
12
|
-
export declare const convertTsScriptsToJs: (cwd?: string) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Converts TypeScript files to JavaScript.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} cwd - Current directory
|
|
17
|
-
* @param {string[]} files - Collection of files to convert
|
|
18
|
-
*/
|
|
19
|
-
export declare const convertTsFilesToJs: (cwd: string, files: string[]) => Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Get all the source code from a Redwood project
|
|
22
|
-
*/
|
|
23
|
-
export declare const typeScriptSourceFiles: (cwd: string, globPattern?: string) => string[];
|
|
24
|
-
/**
|
|
25
|
-
* Read the contents of a TypeScript file, transpile it to JavaScript,
|
|
26
|
-
* but leave the JSX intact and format via Prettier.
|
|
27
|
-
*
|
|
28
|
-
* @param {string} file - The path to the TypeScript file.
|
|
29
|
-
*/
|
|
30
|
-
export declare const transformTSToJS: (file: string) => Promise<string> | undefined;
|
|
31
|
-
export declare const getPrettierConfig: () => Promise<any>;
|
|
32
|
-
/**
|
|
33
|
-
* Prettify `code` according to the extension in `filename`.
|
|
34
|
-
* This will also read a user's `prettier.config.cjs` file if it exists.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} code
|
|
37
|
-
* @param {string} filename
|
|
38
|
-
*/
|
|
39
|
-
export declare const prettify: (code: string, filename: string) => Promise<string>;
|
|
40
|
-
//# sourceMappingURL=ts2js.d.ts.map
|
package/dist/ts2js.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ts2js.d.ts","sourceRoot":"","sources":["../src/ts2js.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAqB,SAGzD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAqB,SAGzD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAU,KAAK,MAAM,EAAE,OAAO,MAAM,EAAE,kBAkCpE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,MAAM,EACX,oBAA2C,aAS5C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,gCAwB3C,CAAA;AAED,eAAO,MAAM,iBAAiB,oBAS7B,CAAA;AAsBD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,EAAE,UAAU,MAAM,oBAa5D,CAAA"}
|
package/dist/ts2js.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { transform } from "@babel/core";
|
|
4
|
-
import fg from "fast-glob";
|
|
5
|
-
import { format } from "prettier";
|
|
6
|
-
import { getPaths } from "@cedarjs/project-config";
|
|
7
|
-
const convertTsProjectToJs = (cwd = getPaths().base) => {
|
|
8
|
-
const files = typeScriptSourceFiles(cwd);
|
|
9
|
-
convertTsFilesToJs(cwd, files);
|
|
10
|
-
};
|
|
11
|
-
const convertTsScriptsToJs = (cwd = getPaths().base) => {
|
|
12
|
-
const files = typeScriptSourceFiles(cwd, "scripts/*.{ts,tsx}");
|
|
13
|
-
convertTsFilesToJs(cwd, files);
|
|
14
|
-
};
|
|
15
|
-
const convertTsFilesToJs = async (cwd, files) => {
|
|
16
|
-
if (files.length === 0) {
|
|
17
|
-
console.log("No TypeScript files found to convert to JS in this project.");
|
|
18
|
-
}
|
|
19
|
-
for (const f of files) {
|
|
20
|
-
const code = await transformTSToJS(f);
|
|
21
|
-
if (code) {
|
|
22
|
-
fs.writeFileSync(
|
|
23
|
-
path.join(cwd, f.replace(".tsx", ".jsx").replace(".ts", ".js")),
|
|
24
|
-
code,
|
|
25
|
-
"utf8"
|
|
26
|
-
);
|
|
27
|
-
fs.unlinkSync(path.join(cwd, f));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (fs.existsSync(path.join(cwd, "api/tsconfig.json"))) {
|
|
31
|
-
fs.renameSync(
|
|
32
|
-
path.join(cwd, "api/tsconfig.json"),
|
|
33
|
-
path.join(cwd, "api/jsconfig.json")
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (fs.existsSync(path.join(cwd, "web/tsconfig.json"))) {
|
|
37
|
-
fs.renameSync(
|
|
38
|
-
path.join(cwd, "web/tsconfig.json"),
|
|
39
|
-
path.join(cwd, "web/jsconfig.json")
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
if (fs.existsSync(path.join(cwd, "scripts/tsconfig.json"))) {
|
|
43
|
-
fs.renameSync(
|
|
44
|
-
path.join(cwd, "scripts/tsconfig.json"),
|
|
45
|
-
path.join(cwd, "scripts/jsconfig.json")
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const typeScriptSourceFiles = (cwd, globPattern = "{api,web}/src/**/*.{ts,tsx}") => {
|
|
50
|
-
console.log(globPattern);
|
|
51
|
-
return fg.sync(globPattern, {
|
|
52
|
-
cwd,
|
|
53
|
-
ignore: ["node_modules"]
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const transformTSToJS = (file) => {
|
|
57
|
-
const tsCode = fs.readFileSync(file, "utf8");
|
|
58
|
-
const filename = path.basename(file);
|
|
59
|
-
const result = transform(tsCode, {
|
|
60
|
-
filename,
|
|
61
|
-
cwd: getPaths().base,
|
|
62
|
-
configFile: false,
|
|
63
|
-
plugins: [
|
|
64
|
-
[
|
|
65
|
-
"@babel/plugin-transform-typescript",
|
|
66
|
-
{
|
|
67
|
-
isTSX: true,
|
|
68
|
-
allExtensions: true
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
],
|
|
72
|
-
retainLines: true
|
|
73
|
-
});
|
|
74
|
-
if (!result?.code) {
|
|
75
|
-
return void 0;
|
|
76
|
-
}
|
|
77
|
-
return prettify(result.code, filename.replace(/\.ts$/, ".js"));
|
|
78
|
-
};
|
|
79
|
-
const getPrettierConfig = async () => {
|
|
80
|
-
try {
|
|
81
|
-
const { default: prettierConfig } = await import(`file://${path.join(getPaths().base, "prettier.config.cjs")}`);
|
|
82
|
-
return prettierConfig;
|
|
83
|
-
} catch {
|
|
84
|
-
return void 0;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const prettierParser = (filename) => {
|
|
88
|
-
switch (path.extname(filename.replace(".template", ""))) {
|
|
89
|
-
case ".css":
|
|
90
|
-
return "css";
|
|
91
|
-
case ".js":
|
|
92
|
-
return "babel";
|
|
93
|
-
case ".ts":
|
|
94
|
-
case ".tsx":
|
|
95
|
-
return "babel-ts";
|
|
96
|
-
default:
|
|
97
|
-
return void 0;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const prettify = async (code, filename) => {
|
|
101
|
-
const parser = prettierParser(filename);
|
|
102
|
-
if (typeof parser === "undefined") {
|
|
103
|
-
return code;
|
|
104
|
-
}
|
|
105
|
-
const prettierConfig = await getPrettierConfig();
|
|
106
|
-
return format(code, {
|
|
107
|
-
...prettierConfig,
|
|
108
|
-
parser
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
export {
|
|
112
|
-
convertTsFilesToJs,
|
|
113
|
-
convertTsProjectToJs,
|
|
114
|
-
convertTsScriptsToJs,
|
|
115
|
-
getPrettierConfig,
|
|
116
|
-
prettify,
|
|
117
|
-
transformTSToJS,
|
|
118
|
-
typeScriptSourceFiles
|
|
119
|
-
};
|