@storm-software/cloudflare-tools 0.71.9 → 0.71.11
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 +31 -0
- package/dist/{chunk-YJWEM35L.js → chunk-6UFA7ZHQ.js} +4 -4
- package/dist/{chunk-WSBHUYOP.mjs → chunk-CR6EQNNW.mjs} +15 -11
- package/dist/{chunk-LM6WK3E2.mjs → chunk-LR6YPKJY.mjs} +3 -3
- package/dist/chunk-MAE2ZXHO.mjs +223 -0
- package/dist/{chunk-TH652DGF.mjs → chunk-O2OONDQ5.mjs} +4 -4
- package/dist/chunk-PQPQASGG.mjs +265 -0
- package/dist/{chunk-2SRZ2J7D.js → chunk-RHLSRXYD.js} +23 -19
- package/dist/chunk-T6V63PPD.js +223 -0
- package/dist/chunk-WEED6TPY.js +262 -0
- package/dist/{chunk-TEQKECUN.js → chunk-ZHOESZRM.js} +4 -4
- package/dist/executors.js +1 -1
- package/dist/executors.mjs +1 -1
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/src/executors/r2-upload-publish/executor.js +2 -2
- package/dist/src/executors/r2-upload-publish/executor.mjs +1 -1
- package/dist/src/generators/init/generator.js +2 -2
- package/dist/src/generators/init/generator.mjs +1 -1
- package/dist/src/generators/worker/generator.js +3 -3
- package/dist/src/generators/worker/generator.mjs +2 -2
- package/package.json +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkN7FW365Qjs = require('./chunk-N7FW365Q.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkUAKLE2QOjs = require('./chunk-UAKLE2QO.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -34,6 +34,9 @@ async function runExecutor(options, context) {
|
|
|
34
34
|
if (!context.projectName) {
|
|
35
35
|
throw new Error("The executor requires a projectName.");
|
|
36
36
|
}
|
|
37
|
+
if (!options.path) {
|
|
38
|
+
throw new Error("The executor requires the `path` option to upload.");
|
|
39
|
+
}
|
|
37
40
|
console.info(
|
|
38
41
|
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
39
42
|
);
|
|
@@ -43,8 +46,7 @@ async function runExecutor(options, context) {
|
|
|
43
46
|
try {
|
|
44
47
|
const workspaceRoot = _chunkVKMAYBQXjs.findWorkspaceRoot.call(void 0, );
|
|
45
48
|
const config = await _chunkVKMAYBQXjs.getConfig.call(void 0, workspaceRoot);
|
|
46
|
-
const
|
|
47
|
-
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
|
|
49
|
+
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.name]), () => ( context.projectName));
|
|
48
50
|
const projectDetails = _chunkN7FW365Qjs.getPackageInfo.call(void 0,
|
|
49
51
|
context.projectsConfigurations.projects[context.projectName]
|
|
50
52
|
);
|
|
@@ -58,17 +60,17 @@ async function runExecutor(options, context) {
|
|
|
58
60
|
args.push("--dry-run");
|
|
59
61
|
}
|
|
60
62
|
const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
61
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
63
|
+
if (!_optionalChain([options, 'optionalAccess', _11 => _11.registry]) && !cloudflareAccountId) {
|
|
62
64
|
throw new Error(
|
|
63
|
-
"The registry option and `CLOUDFLARE_ACCOUNT_ID` environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
|
|
65
|
+
"The registry option and `CLOUDFLARE_ACCOUNT_ID` (or `STORM_BOT_CLOUDFLARE_ACCOUNT`) environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
|
|
64
66
|
);
|
|
65
67
|
}
|
|
66
|
-
if (!process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.
|
|
68
|
+
if (!process.env.STORM_BOT_ACCESS_KEY_ID && !process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.STORM_BOT_SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
67
69
|
throw new Error(
|
|
68
|
-
"The `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
|
|
70
|
+
"The `ACCESS_KEY_ID` (or `STORM_BOT_ACCESS_KEY_ID`) and `SECRET_ACCESS_KEY` (or `STORM_BOT_SECRET_ACCESS_KEY`) environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
|
|
69
71
|
);
|
|
70
72
|
}
|
|
71
|
-
const registry = _optionalChain([options, 'optionalAccess',
|
|
73
|
+
const registry = _optionalChain([options, 'optionalAccess', _12 => _12.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
72
74
|
let projectGraph;
|
|
73
75
|
try {
|
|
74
76
|
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
@@ -88,15 +90,17 @@ async function runExecutor(options, context) {
|
|
|
88
90
|
region: "auto",
|
|
89
91
|
endpoint: registry,
|
|
90
92
|
credentials: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
94
|
+
accessKeyId: process.env.STORM_BOT_ACCESS_KEY_ID || process.env.CLOUDFLARE_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID || process.env.ACCESS_KEY_ID,
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
+
secretAccessKey: process.env.STORM_BOT_SECRET_ACCESS_KEY || process.env.CLOUDFLARE_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY || process.env.SECRET_ACCESS_KEY
|
|
93
97
|
}
|
|
94
98
|
});
|
|
95
|
-
const version = _optionalChain([projectDetails, 'optionalAccess',
|
|
99
|
+
const version = _optionalChain([projectDetails, 'optionalAccess', _13 => _13.content, 'optionalAccess', _14 => _14.version]);
|
|
96
100
|
if (version) {
|
|
97
101
|
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Starting upload version ${version}`);
|
|
98
102
|
}
|
|
99
|
-
const basePath = options.path
|
|
103
|
+
const basePath = options.path;
|
|
100
104
|
const files = await _glob.glob.call(void 0, _chunkZ2WQB55Rjs.joinPaths.call(void 0, basePath, "**/*"), {
|
|
101
105
|
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
102
106
|
});
|
|
@@ -111,7 +115,7 @@ async function runExecutor(options, context) {
|
|
|
111
115
|
ret[dep.name] = "latest";
|
|
112
116
|
}
|
|
113
117
|
return ret;
|
|
114
|
-
}, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess',
|
|
118
|
+
}, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content, 'access', _16 => _16.dependencies]), () => ( {})));
|
|
115
119
|
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
116
120
|
if (options.clean === true) {
|
|
117
121
|
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Clearing out existing items in ${bucketPath}`);
|
|
@@ -120,7 +124,7 @@ async function runExecutor(options, context) {
|
|
|
120
124
|
Bucket: bucketId,
|
|
121
125
|
Prefix: bucketPath
|
|
122
126
|
});
|
|
123
|
-
if (_optionalChain([response, 'optionalAccess',
|
|
127
|
+
if (_optionalChain([response, 'optionalAccess', _17 => _17.Contents]) && response.Contents.length > 0) {
|
|
124
128
|
_chunkZ2WQB55Rjs.writeTrace.call(void 0,
|
|
125
129
|
`Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
126
130
|
);
|
|
@@ -153,8 +157,8 @@ async function runExecutor(options, context) {
|
|
|
153
157
|
name: context.projectName,
|
|
154
158
|
version,
|
|
155
159
|
release,
|
|
156
|
-
description: _optionalChain([projectDetails, 'optionalAccess',
|
|
157
|
-
tags: _optionalChain([projectDetails, 'optionalAccess',
|
|
160
|
+
description: _optionalChain([projectDetails, 'optionalAccess', _18 => _18.content, 'optionalAccess', _19 => _19.description]),
|
|
161
|
+
tags: _optionalChain([projectDetails, 'optionalAccess', _20 => _20.content, 'optionalAccess', _21 => _21.keywords]),
|
|
158
162
|
dependencies,
|
|
159
163
|
devDependencies: null,
|
|
160
164
|
internalDependencies: internalDependencies.filter(
|
|
@@ -163,8 +167,8 @@ async function runExecutor(options, context) {
|
|
|
163
167
|
)
|
|
164
168
|
).map((dep) => dep.name)
|
|
165
169
|
};
|
|
166
|
-
if (_optionalChain([projectDetails, 'optionalAccess',
|
|
167
|
-
meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess',
|
|
170
|
+
if (_optionalChain([projectDetails, 'optionalAccess', _22 => _22.type]) === "package.json") {
|
|
171
|
+
meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess', _23 => _23.content, 'optionalAccess', _24 => _24.devDependencies]);
|
|
168
172
|
}
|
|
169
173
|
const metaJson = JSON.stringify(meta);
|
|
170
174
|
_chunkZ2WQB55Rjs.writeTrace.call(void 0, `Generating meta.json file:
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkUAKLE2QOjs = require('./chunk-UAKLE2QO.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkN7FW365Qjs = require('./chunk-N7FW365Q.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkVKMAYBQXjs = require('./chunk-VKMAYBQX.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkZ2WQB55Rjs = require('./chunk-Z2WQB55R.js');
|
|
21
|
+
|
|
22
|
+
// src/executors/r2-upload-publish/executor.ts
|
|
23
|
+
var _clients3 = require('@aws-sdk/client-s3');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _devkit = require('@nx/devkit');
|
|
28
|
+
var _glob = require('glob');
|
|
29
|
+
var _mimetypes = require('mime-types'); var _mimetypes2 = _interopRequireDefault(_mimetypes);
|
|
30
|
+
var _child_process = require('child_process');
|
|
31
|
+
var _promises = require('fs/promises');
|
|
32
|
+
async function runExecutor(options, context) {
|
|
33
|
+
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
34
|
+
if (!context.projectName) {
|
|
35
|
+
throw new Error("The executor requires a projectName.");
|
|
36
|
+
}
|
|
37
|
+
if (!options.path) {
|
|
38
|
+
throw new Error("The executor requires the `path` option to upload.");
|
|
39
|
+
}
|
|
40
|
+
console.info(
|
|
41
|
+
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
42
|
+
);
|
|
43
|
+
if (!context.projectName || !_optionalChain([context, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects]) || !context.projectsConfigurations.projects[context.projectName] || !_optionalChain([context, 'access', _3 => _3.projectsConfigurations, 'access', _4 => _4.projects, 'access', _5 => _5[context.projectName], 'optionalAccess', _6 => _6.root])) {
|
|
44
|
+
throw new Error("The executor requires projectsConfigurations.");
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const workspaceRoot = _chunkVKMAYBQXjs.findWorkspaceRoot.call(void 0, );
|
|
48
|
+
const config = await _chunkVKMAYBQXjs.getConfig.call(void 0, workspaceRoot);
|
|
49
|
+
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.name]), () => ( context.projectName));
|
|
50
|
+
const projectDetails = _chunkN7FW365Qjs.getPackageInfo.call(void 0,
|
|
51
|
+
context.projectsConfigurations.projects[context.projectName]
|
|
52
|
+
);
|
|
53
|
+
const bucketId = options.bucketId;
|
|
54
|
+
const bucketPath = options.bucketPath || "/";
|
|
55
|
+
if (!bucketId) {
|
|
56
|
+
throw new Error("The executor requires a bucketId.");
|
|
57
|
+
}
|
|
58
|
+
const args = _chunkN7FW365Qjs.createCliOptions.call(void 0, { ...options });
|
|
59
|
+
if (isDryRun) {
|
|
60
|
+
args.push("--dry-run");
|
|
61
|
+
}
|
|
62
|
+
const cloudflareAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
63
|
+
if (!_optionalChain([options, 'optionalAccess', _11 => _11.registry]) && !cloudflareAccountId) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
"The registry option and `CLOUDFLARE_ACCOUNT_ID` (or `STORM_BOT_CLOUDFLARE_ACCOUNT`) environment variable are not set. Please set one of these values to upload to the Cloudflare R2 bucket."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (!process.env.STORM_BOT_ACCESS_KEY_ID && !process.env.ACCESS_KEY_ID && !process.env.CLOUDFLARE_ACCESS_KEY_ID && !process.env.AWS_ACCESS_KEY_ID || !process.env.STORM_BOT_SECRET_ACCESS_KEY && !process.env.CLOUDFLARE_SECRET_ACCESS_KEY && !process.env.SECRET_ACCESS_KEY && !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
"The `ACCESS_KEY_ID` (or `STORM_BOT_ACCESS_KEY_ID`) and `SECRET_ACCESS_KEY` (or `STORM_BOT_SECRET_ACCESS_KEY`) environment variables are not set. Please set these environment variables to upload to the Cloudflare R2 bucket."
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const registry = _optionalChain([options, 'optionalAccess', _12 => _12.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
74
|
+
let projectGraph;
|
|
75
|
+
try {
|
|
76
|
+
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
77
|
+
} catch (e) {
|
|
78
|
+
await _devkit.createProjectGraphAsync.call(void 0, );
|
|
79
|
+
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
80
|
+
}
|
|
81
|
+
if (!projectGraph) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"The executor failed because the project graph is not available. Please run the build command again."
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0,
|
|
87
|
+
`Publishing ${context.projectName} to the ${bucketId} R2 Bucket (at ${registry})`
|
|
88
|
+
);
|
|
89
|
+
const client = new (0, _clients3.S3)({
|
|
90
|
+
region: "auto",
|
|
91
|
+
endpoint: registry,
|
|
92
|
+
credentials: {
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
94
|
+
accessKeyId: process.env.STORM_BOT_ACCESS_KEY_ID || process.env.CLOUDFLARE_ACCESS_KEY_ID || process.env.AWS_ACCESS_KEY_ID || process.env.ACCESS_KEY_ID,
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
+
secretAccessKey: process.env.STORM_BOT_SECRET_ACCESS_KEY || process.env.CLOUDFLARE_SECRET_ACCESS_KEY || process.env.AWS_SECRET_ACCESS_KEY || process.env.SECRET_ACCESS_KEY
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const version = _optionalChain([projectDetails, 'optionalAccess', _13 => _13.content, 'optionalAccess', _14 => _14.version]);
|
|
100
|
+
if (version) {
|
|
101
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Starting upload version ${version}`);
|
|
102
|
+
}
|
|
103
|
+
const basePath = options.path;
|
|
104
|
+
const files = await _glob.glob.call(void 0, _chunkZ2WQB55Rjs.joinPaths.call(void 0, basePath, "**/*"), {
|
|
105
|
+
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
106
|
+
});
|
|
107
|
+
const internalDependencies = await _chunkUAKLE2QOjs.getInternalDependencies.call(void 0,
|
|
108
|
+
context.projectName,
|
|
109
|
+
projectGraph
|
|
110
|
+
);
|
|
111
|
+
const dependencies = internalDependencies.filter(
|
|
112
|
+
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
113
|
+
).reduce((ret, dep) => {
|
|
114
|
+
if (!ret[dep.name]) {
|
|
115
|
+
ret[dep.name] = "latest";
|
|
116
|
+
}
|
|
117
|
+
return ret;
|
|
118
|
+
}, _nullishCoalesce(_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content, 'access', _16 => _16.dependencies]), () => ( {})));
|
|
119
|
+
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
120
|
+
if (options.clean === true) {
|
|
121
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0, `Clearing out existing items in ${bucketPath}`);
|
|
122
|
+
if (!isDryRun) {
|
|
123
|
+
const response = await client.listObjects({
|
|
124
|
+
Bucket: bucketId,
|
|
125
|
+
Prefix: bucketPath
|
|
126
|
+
});
|
|
127
|
+
if (_optionalChain([response, 'optionalAccess', _17 => _17.Contents]) && response.Contents.length > 0) {
|
|
128
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0,
|
|
129
|
+
`Deleting the following existing items from the R2 bucket path ${bucketPath}: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
130
|
+
);
|
|
131
|
+
await Promise.all(
|
|
132
|
+
response.Contents.map(
|
|
133
|
+
(item) => client.deleteObjects({
|
|
134
|
+
Bucket: bucketId,
|
|
135
|
+
Delete: {
|
|
136
|
+
Objects: [
|
|
137
|
+
{
|
|
138
|
+
Key: item.Key
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
Quiet: false
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
} else {
|
|
147
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0,
|
|
148
|
+
`No existing items to delete in the R2 bucket path ${bucketPath}`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
_chunkZ2WQB55Rjs.writeWarning.call(void 0, "[Dry run]: Skipping R2 bucket clean.");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (options.writeMetaJson === true) {
|
|
156
|
+
const meta = {
|
|
157
|
+
name: context.projectName,
|
|
158
|
+
version,
|
|
159
|
+
release,
|
|
160
|
+
description: _optionalChain([projectDetails, 'optionalAccess', _18 => _18.content, 'optionalAccess', _19 => _19.description]),
|
|
161
|
+
tags: _optionalChain([projectDetails, 'optionalAccess', _20 => _20.content, 'optionalAccess', _21 => _21.keywords]),
|
|
162
|
+
dependencies,
|
|
163
|
+
devDependencies: null,
|
|
164
|
+
internalDependencies: internalDependencies.filter(
|
|
165
|
+
(projectNode) => projectNode.data.tags && projectNode.data.tags.some(
|
|
166
|
+
(tag) => tag.toLowerCase() === "component"
|
|
167
|
+
)
|
|
168
|
+
).map((dep) => dep.name)
|
|
169
|
+
};
|
|
170
|
+
if (_optionalChain([projectDetails, 'optionalAccess', _22 => _22.type]) === "package.json") {
|
|
171
|
+
meta.devDependencies = _optionalChain([projectDetails, 'optionalAccess', _23 => _23.content, 'optionalAccess', _24 => _24.devDependencies]);
|
|
172
|
+
}
|
|
173
|
+
const metaJson = JSON.stringify(meta);
|
|
174
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0, `Generating meta.json file:
|
|
175
|
+
${metaJson}`);
|
|
176
|
+
await _chunkUAKLE2QOjs.r2UploadFile.call(void 0,
|
|
177
|
+
client,
|
|
178
|
+
bucketId,
|
|
179
|
+
bucketPath,
|
|
180
|
+
"meta.json",
|
|
181
|
+
version,
|
|
182
|
+
metaJson,
|
|
183
|
+
"application/json",
|
|
184
|
+
isDryRun
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
await Promise.all(
|
|
188
|
+
files.map(async (file) => {
|
|
189
|
+
const name = _chunkZ2WQB55Rjs.correctPaths.call(void 0, file).replace(_chunkZ2WQB55Rjs.correctPaths.call(void 0, basePath), "");
|
|
190
|
+
const type = _mimetypes2.default.lookup(name) || "application/octet-stream";
|
|
191
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0, `Uploading file: ${name} (content-type: ${type})`);
|
|
192
|
+
await _chunkUAKLE2QOjs.r2UploadFile.call(void 0,
|
|
193
|
+
client,
|
|
194
|
+
bucketId,
|
|
195
|
+
bucketPath,
|
|
196
|
+
name,
|
|
197
|
+
version,
|
|
198
|
+
await _promises.readFile.call(void 0, file, { encoding: "utf8" }),
|
|
199
|
+
type,
|
|
200
|
+
isDryRun
|
|
201
|
+
);
|
|
202
|
+
})
|
|
203
|
+
);
|
|
204
|
+
_chunkZ2WQB55Rjs.writeSuccess.call(void 0,
|
|
205
|
+
`Successfully uploaded the ${projectName} project to the Cloudflare R2 bucket.`,
|
|
206
|
+
config
|
|
207
|
+
);
|
|
208
|
+
return {
|
|
209
|
+
success: true
|
|
210
|
+
};
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error("Failed to publish to Cloudflare R2 bucket");
|
|
213
|
+
console.error(error);
|
|
214
|
+
console.log("");
|
|
215
|
+
return {
|
|
216
|
+
success: false
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
exports.runExecutor = runExecutor;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkZHOESZRMjs = require('./chunk-ZHOESZRM.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkVKMAYBQXjs = require('./chunk-VKMAYBQX.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkZ2WQB55Rjs = require('./chunk-Z2WQB55R.js');
|
|
16
|
+
|
|
17
|
+
// src/generators/worker/generator.ts
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var _devkit = require('@nx/devkit');
|
|
30
|
+
var _projectnameandrootutils = require('@nx/devkit/src/generators/project-name-and-root-utils');
|
|
31
|
+
var _node = require('@nx/node');
|
|
32
|
+
var _versions = require('@nx/node/src/utils/versions');
|
|
33
|
+
var _path = require('path');
|
|
34
|
+
|
|
35
|
+
// src/generators/worker/libs/get-account-id.ts
|
|
36
|
+
function getAccountId(accountId) {
|
|
37
|
+
return `account_id = "${accountId}"`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/generators/worker/libs/vitest-imports.ts
|
|
41
|
+
var vitestImports = `import { describe, expect, it, beforeAll, afterAll } from 'vitest';`;
|
|
42
|
+
|
|
43
|
+
// src/generators/worker/libs/vitest-script.ts
|
|
44
|
+
var vitestScript = `"test": "vitest run"`;
|
|
45
|
+
|
|
46
|
+
// src/generators/worker/generator.ts
|
|
47
|
+
async function applicationGenerator(tree, schema) {
|
|
48
|
+
const stopwatch = _chunkZ2WQB55Rjs.getStopwatch.call(void 0, "Storm Worker generator");
|
|
49
|
+
let config;
|
|
50
|
+
try {
|
|
51
|
+
_chunkZ2WQB55Rjs.writeInfo.call(void 0, `\u26A1 Running the Storm Worker generator...
|
|
52
|
+
|
|
53
|
+
`, config);
|
|
54
|
+
const workspaceRoot = _chunkVKMAYBQXjs.findWorkspaceRoot.call(void 0, );
|
|
55
|
+
_chunkZ2WQB55Rjs.writeDebug.call(void 0,
|
|
56
|
+
`Loading the Storm Config from environment variables and storm.json file...
|
|
57
|
+
- workspaceRoot: ${workspaceRoot}`,
|
|
58
|
+
config
|
|
59
|
+
);
|
|
60
|
+
config = await _chunkVKMAYBQXjs.getConfig.call(void 0, workspaceRoot);
|
|
61
|
+
_chunkZ2WQB55Rjs.writeTrace.call(void 0,
|
|
62
|
+
`Loaded Storm config into env:
|
|
63
|
+
${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
|
|
64
|
+
config
|
|
65
|
+
);
|
|
66
|
+
const options = await normalizeOptions(tree, schema, config);
|
|
67
|
+
const tasks = [];
|
|
68
|
+
tasks.push(
|
|
69
|
+
await _chunkZHOESZRMjs.generator_default.call(void 0, tree, {
|
|
70
|
+
...options,
|
|
71
|
+
skipFormat: true
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
tasks.push(
|
|
75
|
+
await _node.applicationGenerator.call(void 0, tree, {
|
|
76
|
+
...options,
|
|
77
|
+
framework: "none",
|
|
78
|
+
skipFormat: true,
|
|
79
|
+
unitTestRunner: options.unitTestRunner == "vitest" ? "none" : options.unitTestRunner,
|
|
80
|
+
e2eTestRunner: "none",
|
|
81
|
+
name: schema.name
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
if (options.unitTestRunner === "vitest") {
|
|
85
|
+
const { vitestGenerator, createOrEditViteConfig } = _devkit.ensurePackage.call(void 0,
|
|
86
|
+
"@nx/vite",
|
|
87
|
+
_versions.nxVersion
|
|
88
|
+
);
|
|
89
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
90
|
+
project: options.name,
|
|
91
|
+
uiFramework: "none",
|
|
92
|
+
coverageProvider: "v8",
|
|
93
|
+
skipFormat: true,
|
|
94
|
+
testEnvironment: "node"
|
|
95
|
+
});
|
|
96
|
+
tasks.push(vitestTask);
|
|
97
|
+
createOrEditViteConfig(
|
|
98
|
+
tree,
|
|
99
|
+
{
|
|
100
|
+
project: options.name,
|
|
101
|
+
includeLib: false,
|
|
102
|
+
includeVitest: true,
|
|
103
|
+
testEnvironment: "node"
|
|
104
|
+
},
|
|
105
|
+
true
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
addCloudflareFiles(tree, options);
|
|
109
|
+
updateTsAppConfig(tree, options);
|
|
110
|
+
addTargets(tree, options);
|
|
111
|
+
if (options.unitTestRunner === "none") {
|
|
112
|
+
removeTestFiles(tree, options);
|
|
113
|
+
}
|
|
114
|
+
if (!options.skipFormat) {
|
|
115
|
+
await _devkit.formatFiles.call(void 0, tree);
|
|
116
|
+
}
|
|
117
|
+
if (options.template === "hono") {
|
|
118
|
+
tasks.push(() => {
|
|
119
|
+
const packageJsonPath = _devkit.joinPathFragments.call(void 0,
|
|
120
|
+
_nullishCoalesce(options.directory, () => ( "")),
|
|
121
|
+
"package.json"
|
|
122
|
+
);
|
|
123
|
+
if (tree.exists(packageJsonPath)) {
|
|
124
|
+
_devkit.updateJson.call(void 0, tree, packageJsonPath, (json) => ({
|
|
125
|
+
...json,
|
|
126
|
+
dependencies: {
|
|
127
|
+
hono: "4.4.0",
|
|
128
|
+
..._optionalChain([json, 'optionalAccess', _ => _.dependencies])
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return _devkit.runTasksInSerial.call(void 0, ...tasks);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
return () => {
|
|
137
|
+
_chunkZ2WQB55Rjs.writeFatal.call(void 0,
|
|
138
|
+
"A fatal error occurred while running the generator - the process was forced to terminate",
|
|
139
|
+
config
|
|
140
|
+
);
|
|
141
|
+
_chunkZ2WQB55Rjs.writeError.call(void 0,
|
|
142
|
+
`An exception was thrown in the generator's process
|
|
143
|
+
- Details: ${error.message}
|
|
144
|
+
- Stacktrace: ${error.stack}`,
|
|
145
|
+
config
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
} finally {
|
|
149
|
+
stopwatch();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function updateTsAppConfig(tree, options) {
|
|
153
|
+
_devkit.updateJson.call(void 0, tree, _path.join.call(void 0, options.appProjectRoot, "tsconfig.app.json"), (json) => {
|
|
154
|
+
json.compilerOptions = {
|
|
155
|
+
...json.compilerOptions,
|
|
156
|
+
esModuleInterop: true,
|
|
157
|
+
target: "es2021",
|
|
158
|
+
lib: ["es2021"],
|
|
159
|
+
module: "es2022",
|
|
160
|
+
moduleResolution: "node",
|
|
161
|
+
resolveJsonModule: true,
|
|
162
|
+
allowJs: true,
|
|
163
|
+
checkJs: false,
|
|
164
|
+
noEmit: true,
|
|
165
|
+
isolatedModules: true,
|
|
166
|
+
allowSyntheticDefaultImports: true,
|
|
167
|
+
forceConsistentCasingInFileNames: true,
|
|
168
|
+
strict: true,
|
|
169
|
+
skipLibCheck: true
|
|
170
|
+
};
|
|
171
|
+
json.compilerOptions.types = [
|
|
172
|
+
...json.compilerOptions.types,
|
|
173
|
+
"@cloudflare/workers-types"
|
|
174
|
+
];
|
|
175
|
+
return json;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function addCloudflareFiles(tree, options) {
|
|
179
|
+
tree.delete(_path.join.call(void 0, options.appProjectRoot, "src/main.ts"));
|
|
180
|
+
_devkit.generateFiles.call(void 0,
|
|
181
|
+
tree,
|
|
182
|
+
_path.join.call(void 0, __dirname, "./files/common"),
|
|
183
|
+
options.appProjectRoot,
|
|
184
|
+
{
|
|
185
|
+
...options,
|
|
186
|
+
tmpl: "",
|
|
187
|
+
name: options.name,
|
|
188
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
189
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : ""
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
if (options.template && options.template !== "none") {
|
|
193
|
+
_devkit.generateFiles.call(void 0,
|
|
194
|
+
tree,
|
|
195
|
+
_path.join.call(void 0, __dirname, `./files/${options.template}`),
|
|
196
|
+
_path.join.call(void 0, options.appProjectRoot, "src"),
|
|
197
|
+
{
|
|
198
|
+
...options,
|
|
199
|
+
tmpl: "",
|
|
200
|
+
name: options.name,
|
|
201
|
+
accountId: options.accountId ? getAccountId(options.accountId) : "",
|
|
202
|
+
vitestScript: options.unitTestRunner === "vitest" ? vitestScript : "",
|
|
203
|
+
vitestImports: options.unitTestRunner === "vitest" ? vitestImports : ""
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function addTargets(tree, options) {
|
|
209
|
+
try {
|
|
210
|
+
const projectConfiguration = _devkit.readProjectConfiguration.call(void 0, tree, options.name);
|
|
211
|
+
projectConfiguration.targets = {
|
|
212
|
+
..._nullishCoalesce(projectConfiguration.targets, () => ( {})),
|
|
213
|
+
serve: {
|
|
214
|
+
executor: "@storm-software/cloudflare-tools:serve",
|
|
215
|
+
options: {
|
|
216
|
+
port: options.port
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"nx-release-publish": {
|
|
220
|
+
executor: "@storm-software/cloudflare-tools:cloudflare-publish"
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
if (projectConfiguration.targets.build) {
|
|
224
|
+
delete projectConfiguration.targets.build;
|
|
225
|
+
}
|
|
226
|
+
_devkit.updateProjectConfiguration.call(void 0, tree, options.name, projectConfiguration);
|
|
227
|
+
} catch (e) {
|
|
228
|
+
console.error(e);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function removeTestFiles(tree, options) {
|
|
232
|
+
tree.delete(_path.join.call(void 0, options.appProjectRoot, "src", "index.test.ts"));
|
|
233
|
+
}
|
|
234
|
+
async function normalizeOptions(host, options, config) {
|
|
235
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await _projectnameandrootutils.determineProjectNameAndRootOptions.call(void 0, host, {
|
|
236
|
+
name: options.name,
|
|
237
|
+
projectType: "application",
|
|
238
|
+
directory: options.directory,
|
|
239
|
+
rootProject: options.rootProject
|
|
240
|
+
});
|
|
241
|
+
options.rootProject = appProjectRoot === ".";
|
|
242
|
+
return {
|
|
243
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== "false",
|
|
244
|
+
accountId: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
|
|
245
|
+
...options,
|
|
246
|
+
name: _devkit.names.call(void 0, appProjectName).fileName,
|
|
247
|
+
frontendProject: options.frontendProject ? _devkit.names.call(void 0, options.frontendProject).fileName : void 0,
|
|
248
|
+
appProjectRoot,
|
|
249
|
+
unitTestRunner: _nullishCoalesce(options.unitTestRunner, () => ( "vitest")),
|
|
250
|
+
rootProject: _nullishCoalesce(options.rootProject, () => ( false)),
|
|
251
|
+
template: _nullishCoalesce(options.template, () => ( "fetch-handler")),
|
|
252
|
+
port: _nullishCoalesce(options.port, () => ( 3e3))
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var generator_default2 = applicationGenerator;
|
|
256
|
+
var applicationSchematic = _devkit.convertNxGenerator.call(void 0, applicationGenerator);
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
exports.applicationGenerator = applicationGenerator; exports.generator_default = generator_default2; exports.applicationSchematic = applicationSchematic;
|
|
@@ -7,7 +7,7 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
|
|
|
7
7
|
"package.json"(exports, module) {
|
|
8
8
|
module.exports = {
|
|
9
9
|
name: "@storm-software/cloudflare-tools",
|
|
10
|
-
version: "0.71.
|
|
10
|
+
version: "0.71.10",
|
|
11
11
|
description: "A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.",
|
|
12
12
|
repository: {
|
|
13
13
|
type: "github",
|
|
@@ -136,9 +136,9 @@ var require_package = _chunkMCKGQKYUjs.__commonJS.call(void 0, {
|
|
|
136
136
|
"@nx/js": "catalog:",
|
|
137
137
|
"@nx/node": "catalog:",
|
|
138
138
|
"@nx/web": "catalog:",
|
|
139
|
-
"@storm-software/config": "1.134.
|
|
140
|
-
"@storm-software/config-tools": "1.188.
|
|
141
|
-
"@storm-software/workspace-tools": "1.294.
|
|
139
|
+
"@storm-software/config": "1.134.60",
|
|
140
|
+
"@storm-software/config-tools": "1.188.60",
|
|
141
|
+
"@storm-software/workspace-tools": "1.294.4",
|
|
142
142
|
nx: "catalog:",
|
|
143
143
|
tsup: "catalog:",
|
|
144
144
|
wrangler: ">=3.58.0"
|
package/dist/executors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";require('./chunk-XO66D74Z.js');
|
|
2
2
|
require('./chunk-QBD2OGUY.js');
|
|
3
3
|
require('./chunk-J5JJZJO5.js');
|
|
4
|
-
require('./chunk-
|
|
4
|
+
require('./chunk-T6V63PPD.js');
|
|
5
5
|
require('./chunk-UAKLE2QO.js');
|
|
6
6
|
require('./chunk-N7FW365Q.js');
|
|
7
7
|
require('./chunk-VKMAYBQX.js');
|
package/dist/executors.mjs
CHANGED
package/dist/generators.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWEED6TPYjs = require('./chunk-WEED6TPY.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkZHOESZRMjs = require('./chunk-ZHOESZRM.js');
|
|
10
10
|
require('./chunk-VKMAYBQX.js');
|
|
11
11
|
require('./chunk-Z2WQB55R.js');
|
|
12
12
|
require('./chunk-MCKGQKYU.js');
|
|
@@ -15,4 +15,4 @@ require('./chunk-MCKGQKYU.js');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
exports.applicationGenerator =
|
|
18
|
+
exports.applicationGenerator = _chunkWEED6TPYjs.applicationGenerator; exports.applicationSchematic = _chunkWEED6TPYjs.applicationSchematic; exports.initGenerator = _chunkZHOESZRMjs.initGenerator; exports.initSchematic = _chunkZHOESZRMjs.initSchematic;
|