@storm-software/cloudflare-tools 0.58.2 → 0.59.0
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/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/{chunk-QPABB45G.mjs → chunk-5TUHGXSI.mjs} +1 -1
- package/dist/{chunk-NJBI4AIW.js → chunk-7JMGYMUN.js} +2 -2
- package/dist/{chunk-QQ22YQSB.mjs → chunk-E4FJOPZF.mjs} +1 -1
- package/dist/{chunk-K2RS4LHV.mjs → chunk-GNQ5XIH7.mjs} +13 -16
- package/dist/{chunk-YVLYQXOO.mjs → chunk-GOVRQQWT.mjs} +3 -3
- package/dist/{chunk-UMK4B3XF.js → chunk-PSYJWYNN.js} +2 -2
- package/dist/{chunk-6GOJPDPL.js → chunk-WMNGJUHG.js} +1 -4
- package/dist/{chunk-3MZCAC7V.mjs → chunk-XWRKT3DB.mjs} +2 -2
- package/dist/executors.js +1 -1
- package/dist/executors.mjs +3 -3
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/dist/src/executors/cloudflare-publish/executor.js +1 -1
- package/dist/src/executors/cloudflare-publish/executor.mjs +3 -3
- package/dist/src/executors/r2-upload-publish/executor.mjs +1 -1
- package/dist/src/executors/serve/executor.js +2 -2
- package/dist/src/executors/serve/executor.mjs +2 -2
- package/dist/src/generators/init/generator.js +2 -2
- package/dist/src/generators/init/generator.mjs +2 -2
- package/dist/src/generators/worker/generator.js +3 -3
- package/dist/src/generators/worker/generator.mjs +3 -3
- package/dist/src/utils/index.mjs +1 -1
- package/dist/src/utils/r2-bucket-helpers.mjs +1 -1
- package/dist/tsup.config.mjs +1 -1
- package/package.json +15 -44
- package/.eslintrc.json +0 -35
- package/executors.ts +0 -4
- package/generators.ts +0 -4
- package/index.ts +0 -4
- package/project.json +0 -56
- package/src/executors/cloudflare-publish/executor.ts +0 -100
- package/src/executors/r2-upload-publish/executor.ts +0 -264
- package/src/executors/serve/executor.ts +0 -84
- package/src/generators/init/generator.spec.ts +0 -20
- package/src/generators/init/generator.ts +0 -60
- package/src/generators/init/libs/versions.ts +0 -7
- package/src/generators/worker/generator.spec.ts +0 -20
- package/src/generators/worker/generator.ts +0 -289
- package/src/generators/worker/libs/get-account-id.ts +0 -3
- package/src/generators/worker/libs/vitest-imports.ts +0 -1
- package/src/generators/worker/libs/vitest-script.ts +0 -1
- package/src/plugins/index.ts +0 -137
- package/src/utils/index.ts +0 -1
- package/src/utils/r2-bucket-helpers.ts +0 -56
- package/tsconfig.json +0 -31
- package/tsup.config.ts +0 -27
- /package/{src → dist/src}/executors/cloudflare-publish/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/cloudflare-publish/schema.json +0 -0
- /package/{src → dist/src}/executors/r2-upload-publish/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/r2-upload-publish/schema.json +0 -0
- /package/{src → dist/src}/executors/serve/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/serve/schema.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/init/schema.json +0 -0
- /package/{src → dist/src}/generators/worker/files/common/package.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/common/wrangler.toml__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/fetch-handler/index.test.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/fetch-handler/index.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/hono/index.test.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/hono/index.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/scheduled-handler/index.test.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/files/scheduled-handler/index.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/worker/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/worker/schema.json +0 -0
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
convertNxGenerator,
|
|
3
|
-
ensurePackage,
|
|
4
|
-
formatFiles,
|
|
5
|
-
generateFiles,
|
|
6
|
-
GeneratorCallback,
|
|
7
|
-
joinPathFragments,
|
|
8
|
-
names,
|
|
9
|
-
readProjectConfiguration,
|
|
10
|
-
runTasksInSerial,
|
|
11
|
-
Tree,
|
|
12
|
-
updateJson,
|
|
13
|
-
updateProjectConfiguration
|
|
14
|
-
} from "@nx/devkit";
|
|
15
|
-
import { determineProjectNameAndRootOptions } from "@nx/devkit/src/generators/project-name-and-root-utils";
|
|
16
|
-
import { applicationGenerator as nodeApplicationGenerator } from "@nx/node";
|
|
17
|
-
import { nxVersion } from "@nx/node/src/utils/versions";
|
|
18
|
-
import { StormWorkspaceConfig } from "@storm-software/config";
|
|
19
|
-
import {
|
|
20
|
-
getConfig,
|
|
21
|
-
getStopwatch,
|
|
22
|
-
writeDebug,
|
|
23
|
-
writeError,
|
|
24
|
-
writeFatal,
|
|
25
|
-
writeInfo,
|
|
26
|
-
writeTrace
|
|
27
|
-
} from "@storm-software/config-tools";
|
|
28
|
-
import { findWorkspaceRoot } from "@storm-software/config-tools/utilities/find-workspace-root";
|
|
29
|
-
import { join } from "path";
|
|
30
|
-
import initGenerator from "../init/generator";
|
|
31
|
-
import { getAccountId } from "./libs/get-account-id";
|
|
32
|
-
import { vitestImports } from "./libs/vitest-imports";
|
|
33
|
-
import { vitestScript } from "./libs/vitest-script";
|
|
34
|
-
import type { NormalizedSchema, WorkerGeneratorSchema } from "./schema";
|
|
35
|
-
|
|
36
|
-
export async function applicationGenerator(
|
|
37
|
-
tree: Tree,
|
|
38
|
-
schema: WorkerGeneratorSchema
|
|
39
|
-
) {
|
|
40
|
-
const stopwatch = getStopwatch("Storm Worker generator");
|
|
41
|
-
|
|
42
|
-
let config: StormWorkspaceConfig | undefined;
|
|
43
|
-
try {
|
|
44
|
-
writeInfo(`⚡ Running the Storm Worker generator...\n\n`, config);
|
|
45
|
-
|
|
46
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
47
|
-
|
|
48
|
-
writeDebug(
|
|
49
|
-
`Loading the Storm Config from environment variables and storm.json file...
|
|
50
|
-
- workspaceRoot: ${workspaceRoot}`,
|
|
51
|
-
config
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
config = await getConfig(workspaceRoot);
|
|
55
|
-
writeTrace(
|
|
56
|
-
`Loaded Storm config into env: \n${Object.keys(process.env)
|
|
57
|
-
.map(key => ` - ${key}=${JSON.stringify(process.env[key])}`)
|
|
58
|
-
.join("\n")}`,
|
|
59
|
-
config
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const options = await normalizeOptions(tree, schema, config);
|
|
63
|
-
const tasks: GeneratorCallback[] = [];
|
|
64
|
-
|
|
65
|
-
// Set up the needed packages.
|
|
66
|
-
tasks.push(
|
|
67
|
-
await initGenerator(tree, {
|
|
68
|
-
...options,
|
|
69
|
-
skipFormat: true
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
tasks.push(
|
|
74
|
-
await nodeApplicationGenerator(tree, {
|
|
75
|
-
...options,
|
|
76
|
-
framework: "none",
|
|
77
|
-
skipFormat: true,
|
|
78
|
-
unitTestRunner:
|
|
79
|
-
options.unitTestRunner == "vitest" ? "none" : options.unitTestRunner,
|
|
80
|
-
e2eTestRunner: "none",
|
|
81
|
-
name: schema.name
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
if (options.unitTestRunner === "vitest") {
|
|
86
|
-
const { vitestGenerator, createOrEditViteConfig } = ensurePackage(
|
|
87
|
-
"@nx/vite",
|
|
88
|
-
nxVersion
|
|
89
|
-
);
|
|
90
|
-
const vitestTask = await vitestGenerator(tree, {
|
|
91
|
-
project: options.name,
|
|
92
|
-
uiFramework: "none",
|
|
93
|
-
coverageProvider: "v8",
|
|
94
|
-
skipFormat: true,
|
|
95
|
-
testEnvironment: "node"
|
|
96
|
-
});
|
|
97
|
-
tasks.push(vitestTask);
|
|
98
|
-
createOrEditViteConfig(
|
|
99
|
-
tree,
|
|
100
|
-
{
|
|
101
|
-
project: options.name,
|
|
102
|
-
includeLib: false,
|
|
103
|
-
includeVitest: true,
|
|
104
|
-
testEnvironment: "node"
|
|
105
|
-
},
|
|
106
|
-
true
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
addCloudflareFiles(tree, options);
|
|
111
|
-
updateTsAppConfig(tree, options);
|
|
112
|
-
addTargets(tree, options);
|
|
113
|
-
|
|
114
|
-
if (options.unitTestRunner === "none") {
|
|
115
|
-
removeTestFiles(tree, options);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!options.skipFormat) {
|
|
119
|
-
await formatFiles(tree);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (options.template === "hono") {
|
|
123
|
-
tasks.push(() => {
|
|
124
|
-
const packageJsonPath = joinPathFragments(
|
|
125
|
-
options.directory ?? "",
|
|
126
|
-
"package.json"
|
|
127
|
-
);
|
|
128
|
-
if (tree.exists(packageJsonPath)) {
|
|
129
|
-
updateJson(tree, packageJsonPath, json => ({
|
|
130
|
-
...json,
|
|
131
|
-
dependencies: {
|
|
132
|
-
hono: "4.4.0",
|
|
133
|
-
...json?.dependencies
|
|
134
|
-
}
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return runTasksInSerial(...tasks);
|
|
141
|
-
} catch (error) {
|
|
142
|
-
return () => {
|
|
143
|
-
writeFatal(
|
|
144
|
-
"A fatal error occurred while running the generator - the process was forced to terminate",
|
|
145
|
-
config
|
|
146
|
-
);
|
|
147
|
-
writeError(
|
|
148
|
-
`An exception was thrown in the generator's process \n - Details: ${error.message}\n - Stacktrace: ${error.stack}`,
|
|
149
|
-
config
|
|
150
|
-
);
|
|
151
|
-
};
|
|
152
|
-
} finally {
|
|
153
|
-
stopwatch();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Modify the default tsconfig.app.json generate by the node application generator to support workers.
|
|
158
|
-
function updateTsAppConfig(tree: Tree, options: NormalizedSchema) {
|
|
159
|
-
updateJson(tree, join(options.appProjectRoot, "tsconfig.app.json"), json => {
|
|
160
|
-
json.compilerOptions = {
|
|
161
|
-
...json.compilerOptions,
|
|
162
|
-
esModuleInterop: true,
|
|
163
|
-
target: "es2021",
|
|
164
|
-
lib: ["es2021"],
|
|
165
|
-
module: "es2022",
|
|
166
|
-
moduleResolution: "node",
|
|
167
|
-
resolveJsonModule: true,
|
|
168
|
-
|
|
169
|
-
allowJs: true,
|
|
170
|
-
checkJs: false,
|
|
171
|
-
noEmit: true,
|
|
172
|
-
|
|
173
|
-
isolatedModules: true,
|
|
174
|
-
allowSyntheticDefaultImports: true,
|
|
175
|
-
forceConsistentCasingInFileNames: true,
|
|
176
|
-
|
|
177
|
-
strict: true,
|
|
178
|
-
skipLibCheck: true
|
|
179
|
-
};
|
|
180
|
-
json.compilerOptions.types = [
|
|
181
|
-
...json.compilerOptions.types,
|
|
182
|
-
"@cloudflare/workers-types"
|
|
183
|
-
];
|
|
184
|
-
return json;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Adds the needed files from the common folder and the selected template folder
|
|
189
|
-
function addCloudflareFiles(tree: Tree, options: NormalizedSchema) {
|
|
190
|
-
// Delete main.ts. Workers convention is a file named `index.js` or `index.ts
|
|
191
|
-
tree.delete(join(options.appProjectRoot, "src/main.ts"));
|
|
192
|
-
|
|
193
|
-
// General configuration files for workers
|
|
194
|
-
generateFiles(
|
|
195
|
-
tree,
|
|
196
|
-
join(__dirname, "./files/common"),
|
|
197
|
-
options.appProjectRoot,
|
|
198
|
-
{
|
|
199
|
-
...options,
|
|
200
|
-
tmpl: "",
|
|
201
|
-
name: options.name,
|
|
202
|
-
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
203
|
-
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : ""
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
// Generate template files with workers code
|
|
208
|
-
if (options.template && options.template !== "none") {
|
|
209
|
-
generateFiles(
|
|
210
|
-
tree,
|
|
211
|
-
join(__dirname, `./files/${options.template}`),
|
|
212
|
-
join(options.appProjectRoot, "src"),
|
|
213
|
-
{
|
|
214
|
-
...options,
|
|
215
|
-
tmpl: "",
|
|
216
|
-
name: options.name,
|
|
217
|
-
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
218
|
-
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : "",
|
|
219
|
-
vitestImports: options.unitTestRunner === "vitest" ? vitestImports : ""
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Adds the targets to the project configuration
|
|
226
|
-
function addTargets(tree: Tree, options: NormalizedSchema) {
|
|
227
|
-
try {
|
|
228
|
-
const projectConfiguration = readProjectConfiguration(tree, options.name);
|
|
229
|
-
|
|
230
|
-
projectConfiguration.targets = {
|
|
231
|
-
...(projectConfiguration.targets ?? {}),
|
|
232
|
-
serve: {
|
|
233
|
-
executor: "@storm-software/cloudflare-tools:serve",
|
|
234
|
-
options: {
|
|
235
|
-
port: options.port
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
"nx-release-publish": {
|
|
239
|
-
executor: "@storm-software/cloudflare-tools:cloudflare-publish"
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
if (projectConfiguration.targets.build) {
|
|
244
|
-
delete projectConfiguration.targets.build;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
updateProjectConfiguration(tree, options.name, projectConfiguration);
|
|
248
|
-
} catch (e) {
|
|
249
|
-
console.error(e);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function removeTestFiles(tree: Tree, options: NormalizedSchema) {
|
|
254
|
-
tree.delete(join(options.appProjectRoot, "src", "index.test.ts"));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Transform the options to the normalized schema. Loads defaults options.
|
|
258
|
-
async function normalizeOptions(
|
|
259
|
-
host: Tree,
|
|
260
|
-
options: WorkerGeneratorSchema,
|
|
261
|
-
config?: StormWorkspaceConfig
|
|
262
|
-
): Promise<NormalizedSchema> {
|
|
263
|
-
const { projectName: appProjectName, projectRoot: appProjectRoot } =
|
|
264
|
-
await determineProjectNameAndRootOptions(host, {
|
|
265
|
-
name: options.name,
|
|
266
|
-
projectType: "application",
|
|
267
|
-
directory: options.directory,
|
|
268
|
-
rootProject: options.rootProject
|
|
269
|
-
});
|
|
270
|
-
options.rootProject = appProjectRoot === ".";
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
addPlugin: process.env.NX_ADD_PLUGINS !== "false",
|
|
274
|
-
accountId: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
|
|
275
|
-
...options,
|
|
276
|
-
name: names(appProjectName).fileName,
|
|
277
|
-
frontendProject: options.frontendProject
|
|
278
|
-
? names(options.frontendProject).fileName
|
|
279
|
-
: undefined,
|
|
280
|
-
appProjectRoot,
|
|
281
|
-
unitTestRunner: options.unitTestRunner ?? "vitest",
|
|
282
|
-
rootProject: options.rootProject ?? false,
|
|
283
|
-
template: options.template ?? "fetch-handler",
|
|
284
|
-
port: options.port ?? 3000
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export default applicationGenerator;
|
|
289
|
-
export const applicationSchematic = convertNxGenerator(applicationGenerator);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const vitestImports = `import { describe, expect, it, beforeAll, afterAll } from 'vitest';`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const vitestScript = `"test": "vitest run"`;
|
package/src/plugins/index.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ProjectTagConstants,
|
|
3
|
-
addProjectTag,
|
|
4
|
-
} from "@storm-software/workspace-tools/utils/project-tags";
|
|
5
|
-
import { existsSync } from "node:fs";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { readNxJson } from "nx/src/config/nx-json.js";
|
|
8
|
-
import type { ProjectConfiguration } from "nx/src/config/workspace-json-project-json";
|
|
9
|
-
import { readJsonFile } from "nx/src/utils/fileutils";
|
|
10
|
-
import {
|
|
11
|
-
type PackageJson,
|
|
12
|
-
readTargetsFromPackageJson,
|
|
13
|
-
} from "nx/src/utils/package-json";
|
|
14
|
-
|
|
15
|
-
export const name = "storm-software/cloudflare";
|
|
16
|
-
|
|
17
|
-
export const createNodes = [
|
|
18
|
-
"{**/wrangler.toml}",
|
|
19
|
-
(file, _, ctx) => {
|
|
20
|
-
const packageJson = createPackageJson(file, ctx.workspaceRoot);
|
|
21
|
-
if (!packageJson) {
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const project = createProjectFromPackageJsonNextToProjectJson(
|
|
26
|
-
file,
|
|
27
|
-
packageJson,
|
|
28
|
-
);
|
|
29
|
-
const nxJson = readNxJson(ctx.workspaceRoot);
|
|
30
|
-
|
|
31
|
-
const targets: ProjectConfiguration["targets"] = readTargetsFromPackageJson(
|
|
32
|
-
packageJson,
|
|
33
|
-
nxJson,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
// Apply nx-release-publish target for non-private projects
|
|
37
|
-
|
|
38
|
-
targets["serve"] = {
|
|
39
|
-
cache: false,
|
|
40
|
-
inputs: ["typescript", "^production"],
|
|
41
|
-
dependsOn: ["build"],
|
|
42
|
-
executor: "@storm-software/cloudflare-tools:serve",
|
|
43
|
-
options: {
|
|
44
|
-
port: 4500,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
targets["clean-package"] = {
|
|
49
|
-
cache: true,
|
|
50
|
-
dependsOn: ["build"],
|
|
51
|
-
inputs: ["typescript", "^production"],
|
|
52
|
-
outputs: ["{workspaceRoot}/dist/{projectRoot}"],
|
|
53
|
-
executor: "@storm-software/workspace-tools:clean-package",
|
|
54
|
-
options: {
|
|
55
|
-
cleanReadMe: true,
|
|
56
|
-
cleanComments: true,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
targets["nx-release-publish"] = {
|
|
61
|
-
cache: false,
|
|
62
|
-
inputs: ["typescript", "^production"],
|
|
63
|
-
dependsOn: ["clean-package", "^nx-release-publish"],
|
|
64
|
-
executor: "@storm-software/cloudflare-tools:cloudflare-publish",
|
|
65
|
-
options: {},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
addProjectTag(
|
|
69
|
-
project,
|
|
70
|
-
ProjectTagConstants.ProjectType.TAG_ID,
|
|
71
|
-
project.projectType === "application"
|
|
72
|
-
? ProjectTagConstants.ProjectType.APPLICATION
|
|
73
|
-
: ProjectTagConstants.ProjectType.LIBRARY,
|
|
74
|
-
{ overwrite: true },
|
|
75
|
-
);
|
|
76
|
-
addProjectTag(
|
|
77
|
-
project,
|
|
78
|
-
ProjectTagConstants.DistStyle.TAG_ID,
|
|
79
|
-
ProjectTagConstants.DistStyle.CLEAN,
|
|
80
|
-
{ overwrite: true },
|
|
81
|
-
);
|
|
82
|
-
addProjectTag(project, ProjectTagConstants.Provider.TAG_ID, "cloudflare", {
|
|
83
|
-
overwrite: true,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return project?.name
|
|
87
|
-
? {
|
|
88
|
-
projects: {
|
|
89
|
-
[project.name]: {
|
|
90
|
-
...project,
|
|
91
|
-
targets,
|
|
92
|
-
release: {
|
|
93
|
-
...project?.release,
|
|
94
|
-
version: {
|
|
95
|
-
...project?.release?.version,
|
|
96
|
-
generator: "@storm-software/workspace-tools:release-version",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
}
|
|
102
|
-
: {};
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
function createProjectFromPackageJsonNextToProjectJson(
|
|
107
|
-
projectJsonPath: string,
|
|
108
|
-
packageJson: PackageJson,
|
|
109
|
-
): ProjectConfiguration {
|
|
110
|
-
const { nx, name } = packageJson;
|
|
111
|
-
const root = dirname(projectJsonPath);
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
...nx,
|
|
115
|
-
name,
|
|
116
|
-
root,
|
|
117
|
-
targets: {},
|
|
118
|
-
} as ProjectConfiguration;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function createPackageJson(
|
|
122
|
-
projectJsonPath: string,
|
|
123
|
-
workspaceRoot: string,
|
|
124
|
-
): PackageJson | null {
|
|
125
|
-
try {
|
|
126
|
-
const root = dirname(projectJsonPath);
|
|
127
|
-
const packageJsonPath = join(workspaceRoot, root, "package.json");
|
|
128
|
-
if (!existsSync(packageJsonPath)) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return readJsonFile(packageJsonPath) as PackageJson;
|
|
133
|
-
} catch (e) {
|
|
134
|
-
console.log(e);
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./r2-bucket-helpers";
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { S3 } from "@aws-sdk/client-s3";
|
|
2
|
-
import {
|
|
3
|
-
ProjectGraph,
|
|
4
|
-
ProjectGraphDependency,
|
|
5
|
-
ProjectGraphProjectNode,
|
|
6
|
-
} from "@nx/devkit";
|
|
7
|
-
import { writeDebug, writeWarning } from "@storm-software/config-tools";
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
9
|
-
|
|
10
|
-
export const r2UploadFile = async (
|
|
11
|
-
client: S3,
|
|
12
|
-
bucketName: string,
|
|
13
|
-
projectPath: string,
|
|
14
|
-
fileName: string,
|
|
15
|
-
version: string,
|
|
16
|
-
fileContent: string,
|
|
17
|
-
contentType = "text/plain",
|
|
18
|
-
isDryRun = false,
|
|
19
|
-
) => {
|
|
20
|
-
const checksum = createHash("sha256").update(fileContent).digest("base64");
|
|
21
|
-
const fileKey = `${projectPath}/${fileName.startsWith("/") ? fileName.substring(1) : fileName}`;
|
|
22
|
-
writeDebug(`Uploading file: ${fileKey}`);
|
|
23
|
-
|
|
24
|
-
if (!isDryRun) {
|
|
25
|
-
await client.putObject({
|
|
26
|
-
Bucket: bucketName,
|
|
27
|
-
Key: fileKey,
|
|
28
|
-
Body: fileContent.replaceAll(' from "@cyclone-ui/', ' from "../'),
|
|
29
|
-
ContentType: contentType,
|
|
30
|
-
Metadata: {
|
|
31
|
-
version,
|
|
32
|
-
checksum,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const getInternalDependencies = (
|
|
41
|
-
projectName: string,
|
|
42
|
-
graph: ProjectGraph,
|
|
43
|
-
): ProjectGraphProjectNode[] => {
|
|
44
|
-
const allDeps = graph.dependencies[projectName] ?? [];
|
|
45
|
-
|
|
46
|
-
return Array.from(
|
|
47
|
-
allDeps.reduce(
|
|
48
|
-
(acc: ProjectGraphProjectNode[], node: ProjectGraphDependency) => {
|
|
49
|
-
const found = graph.nodes[node.target];
|
|
50
|
-
if (found) acc.push(found);
|
|
51
|
-
return acc;
|
|
52
|
-
},
|
|
53
|
-
[],
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"rootDir": "../..",
|
|
6
|
-
"target": "ESNext",
|
|
7
|
-
"module": "ESNext",
|
|
8
|
-
"lib": ["ESNext"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"skipDefaultLibCheck": true,
|
|
11
|
-
"moduleResolution": "Bundler",
|
|
12
|
-
"moduleDetection": "force",
|
|
13
|
-
"types": ["node"]
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"executors.ts",
|
|
17
|
-
"generators.ts",
|
|
18
|
-
"index.ts",
|
|
19
|
-
"src/**/*.ts",
|
|
20
|
-
"src/**/*.d.ts",
|
|
21
|
-
"src/**/*.json",
|
|
22
|
-
"tsup.config.ts"
|
|
23
|
-
],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"jest.config.ts",
|
|
26
|
-
"src/generators/**/files/**/*",
|
|
27
|
-
"src/**/untyped.ts",
|
|
28
|
-
"src/**/*.spec.ts",
|
|
29
|
-
"src/**/*.test.ts"
|
|
30
|
-
]
|
|
31
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineConfig, Options } from "tsup";
|
|
2
|
-
|
|
3
|
-
const config = defineConfig([
|
|
4
|
-
{
|
|
5
|
-
name: "cloudflare-tools",
|
|
6
|
-
target: "node22",
|
|
7
|
-
entryPoints: [
|
|
8
|
-
"./*.ts",
|
|
9
|
-
"./src/utils/*.ts",
|
|
10
|
-
"./src/executors/*/executor.ts",
|
|
11
|
-
"./src/generators/*/generator.ts",
|
|
12
|
-
"./src/generators/plugins/*.ts"
|
|
13
|
-
],
|
|
14
|
-
outDir: "dist",
|
|
15
|
-
format: ["cjs", "esm"],
|
|
16
|
-
platform: "node",
|
|
17
|
-
splitting: true,
|
|
18
|
-
clean: true,
|
|
19
|
-
dts: true,
|
|
20
|
-
sourcemap: false,
|
|
21
|
-
shims: true,
|
|
22
|
-
tsconfig: "./tsconfig.json",
|
|
23
|
-
external: ["@storm-software/workspace-tools"]
|
|
24
|
-
}
|
|
25
|
-
]) as Options;
|
|
26
|
-
|
|
27
|
-
export default config;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|