@storm-software/cloudflare-tools 0.55.85 → 0.55.87
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 +24 -0
- package/README.md +1 -1
- package/dist/{chunk-VTHBMY4B.js → chunk-6XDOBG77.js} +39 -28
- package/dist/{chunk-FUE3PSOC.mjs → chunk-CW6SXRL4.mjs} +825 -544
- package/dist/{chunk-VRLPVMXP.mjs → chunk-FABNT5TZ.mjs} +15 -13
- package/dist/{chunk-QQJ225UZ.mjs → chunk-GPAI4NHQ.mjs} +141 -87
- package/dist/{chunk-YNJJF3XM.mjs → chunk-H4XWGL24.mjs} +93 -56
- package/dist/{chunk-IVLCYFXD.js → chunk-HBASMEU5.js} +168 -114
- package/dist/{chunk-6B5PUF7X.js → chunk-HIUZ6UL7.js} +97 -47
- package/dist/{chunk-R7AIVBS7.js → chunk-I4P7DVDN.js} +19 -24
- package/dist/{chunk-KWHACLHR.mjs → chunk-ISGKIYF5.mjs} +92 -42
- package/dist/{chunk-5RE7UZTH.mjs → chunk-L4WFYC7K.mjs} +39 -28
- package/dist/{chunk-PWYTCJYX.js → chunk-LDHIZ5T7.js} +875 -594
- package/dist/{chunk-J5SB6L2L.js → chunk-MCKGQKYU.js} +2 -5
- package/dist/{chunk-DEJ5S46A.mjs → chunk-MV24QW26.mjs} +195 -127
- package/dist/{chunk-V7LBWOVV.js → chunk-PZ5CI56F.js} +196 -128
- package/dist/{chunk-AOEF7EWN.mjs → chunk-QPABB45G.mjs} +19 -24
- package/dist/{chunk-TLFPZXKG.mjs → chunk-QQ22YQSB.mjs} +3 -6
- package/dist/{chunk-QGRENI3O.js → chunk-RIUVF72K.js} +17 -15
- package/dist/{chunk-PKQBY4ZM.js → chunk-X4Y76AIM.js} +26 -20
- package/dist/{chunk-CNGX2WYG.js → chunk-XCEENUJB.js} +93 -58
- package/dist/{chunk-N4KJP2OA.mjs → chunk-YJOYATEB.mjs} +27 -21
- package/dist/executors.js +8 -8
- package/dist/executors.mjs +8 -8
- package/dist/generators.js +6 -6
- package/dist/generators.mjs +5 -5
- package/dist/index.js +41 -49
- package/dist/index.mjs +40 -48
- package/dist/src/executors/cloudflare-publish/executor.js +7 -7
- package/dist/src/executors/cloudflare-publish/executor.mjs +6 -6
- package/dist/src/executors/r2-upload-publish/executor.js +7 -7
- package/dist/src/executors/r2-upload-publish/executor.mjs +6 -6
- package/dist/src/executors/serve/executor.js +49 -50
- package/dist/src/executors/serve/executor.mjs +48 -49
- package/dist/src/generators/init/generator.js +3 -3
- package/dist/src/generators/init/generator.mjs +2 -2
- package/dist/src/generators/worker/generator.js +6 -6
- package/dist/src/generators/worker/generator.mjs +5 -5
- package/dist/src/utils/index.js +4 -4
- package/dist/src/utils/index.mjs +3 -3
- package/dist/src/utils/r2-bucket-helpers.js +4 -4
- package/dist/src/utils/r2-bucket-helpers.mjs +3 -3
- package/dist/tsup.config.js +3 -8
- package/dist/tsup.config.mjs +3 -8
- package/package.json +1 -1
|
@@ -1,27 +1,28 @@
|
|
|
1
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
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkRIUVF72Kjs = require('./chunk-RIUVF72K.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk6XDOBG77js = require('./chunk-6XDOBG77.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkHBASMEU5js = require('./chunk-HBASMEU5.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _chunkJ5SB6L2Ljs = require('./chunk-J5SB6L2L.js');
|
|
18
|
+
var _chunkPZ5CI56Fjs = require('./chunk-PZ5CI56F.js');
|
|
22
19
|
|
|
23
20
|
// src/executors/r2-upload-publish/executor.ts
|
|
24
21
|
var _clients3 = require('@aws-sdk/client-s3');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
25
26
|
var _devkit = require('@nx/devkit');
|
|
26
27
|
var _glob = require('glob');
|
|
27
28
|
var _child_process = require('child_process');
|
|
@@ -31,31 +32,39 @@ async function runExecutor(options, context) {
|
|
|
31
32
|
if (!context.projectName) {
|
|
32
33
|
throw new Error("The executor requires a projectName.");
|
|
33
34
|
}
|
|
34
|
-
console.info(
|
|
35
|
+
console.info(
|
|
36
|
+
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
37
|
+
);
|
|
35
38
|
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])) {
|
|
36
39
|
throw new Error("The executor requires projectsConfigurations.");
|
|
37
40
|
}
|
|
38
41
|
try {
|
|
39
|
-
const workspaceRoot =
|
|
40
|
-
const config = await
|
|
42
|
+
const workspaceRoot = _chunkPZ5CI56Fjs.findWorkspaceRoot.call(void 0, );
|
|
43
|
+
const config = await _chunkHBASMEU5js.getConfig.call(void 0, workspaceRoot);
|
|
41
44
|
const sourceRoot = _nullishCoalesce(_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.sourceRoot]), () => ( workspaceRoot));
|
|
42
45
|
const projectName = _nullishCoalesce(_optionalChain([context, 'access', _11 => _11.projectsConfigurations, 'access', _12 => _12.projects, 'access', _13 => _13[context.projectName], 'optionalAccess', _14 => _14.name]), () => ( context.projectName));
|
|
43
|
-
const projectDetails =
|
|
46
|
+
const projectDetails = _chunk6XDOBG77js.getPackageInfo.call(void 0,
|
|
47
|
+
context.projectsConfigurations.projects[context.projectName]
|
|
48
|
+
);
|
|
44
49
|
if (!_optionalChain([projectDetails, 'optionalAccess', _15 => _15.content])) {
|
|
45
|
-
throw new Error(
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Could not find the project details for ${context.projectName}`
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
|
-
const args =
|
|
48
|
-
...options
|
|
49
|
-
});
|
|
54
|
+
const args = _chunk6XDOBG77js.createCliOptions.call(void 0, { ...options });
|
|
50
55
|
if (isDryRun) {
|
|
51
56
|
args.push("--dry-run");
|
|
52
57
|
}
|
|
53
58
|
const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
54
59
|
if (!_optionalChain([options, 'optionalAccess', _16 => _16.registry]) && !cloudflareAccountId) {
|
|
55
|
-
throw new Error(
|
|
60
|
+
throw new Error(
|
|
61
|
+
"The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
|
|
62
|
+
);
|
|
56
63
|
}
|
|
57
64
|
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
58
|
-
throw new Error(
|
|
65
|
+
throw new Error(
|
|
66
|
+
"The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
|
|
67
|
+
);
|
|
59
68
|
}
|
|
60
69
|
const endpoint = _optionalChain([options, 'optionalAccess', _17 => _17.registry]) ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
61
70
|
let projectGraph;
|
|
@@ -66,9 +75,13 @@ async function runExecutor(options, context) {
|
|
|
66
75
|
projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
67
76
|
}
|
|
68
77
|
if (!projectGraph) {
|
|
69
|
-
throw new Error(
|
|
78
|
+
throw new Error(
|
|
79
|
+
"The executor failed because the project graph is not available. Please run the build command again."
|
|
80
|
+
);
|
|
70
81
|
}
|
|
71
|
-
|
|
82
|
+
_chunkPZ5CI56Fjs.writeInfo.call(void 0,
|
|
83
|
+
`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
|
|
84
|
+
);
|
|
72
85
|
const s3Client = new (0, _clients3.S3)({
|
|
73
86
|
region: "auto",
|
|
74
87
|
endpoint,
|
|
@@ -78,43 +91,56 @@ async function runExecutor(options, context) {
|
|
|
78
91
|
}
|
|
79
92
|
});
|
|
80
93
|
const version = _optionalChain([projectDetails, 'access', _18 => _18.content, 'optionalAccess', _19 => _19.version]);
|
|
81
|
-
|
|
94
|
+
_chunkPZ5CI56Fjs.writeInfo.call(void 0, `Generated component version: ${version}`);
|
|
82
95
|
const files = await _glob.glob.call(void 0, _devkit.joinPathFragments.call(void 0, sourceRoot, "**/*"), {
|
|
83
96
|
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
84
97
|
});
|
|
85
98
|
const projectPath = `registry/${context.projectName}`;
|
|
86
|
-
const internalDependencies = await
|
|
87
|
-
|
|
99
|
+
const internalDependencies = await _chunkRIUVF72Kjs.getInternalDependencies.call(void 0,
|
|
100
|
+
context.projectName,
|
|
101
|
+
projectGraph
|
|
102
|
+
);
|
|
103
|
+
const dependencies = internalDependencies.filter(
|
|
104
|
+
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
105
|
+
).reduce((ret, dep) => {
|
|
88
106
|
if (!ret[dep.name]) {
|
|
89
107
|
ret[dep.name] = "latest";
|
|
90
108
|
}
|
|
91
109
|
return ret;
|
|
92
110
|
}, _nullishCoalesce(projectDetails.content.dependencies, () => ( {})));
|
|
93
111
|
const release = _nullishCoalesce(options.tag, () => ( _child_process.execSync.call(void 0, "npm config get tag").toString().trim()));
|
|
94
|
-
|
|
112
|
+
_chunkPZ5CI56Fjs.writeInfo.call(void 0, `Clearing out existing items in ${projectPath}`);
|
|
95
113
|
if (!isDryRun) {
|
|
96
114
|
const response = await s3Client.listObjects({
|
|
97
115
|
Bucket: options.bucketId,
|
|
98
116
|
Prefix: projectPath
|
|
99
117
|
});
|
|
100
118
|
if (_optionalChain([response, 'optionalAccess', _20 => _20.Contents]) && response.Contents.length > 0) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
_chunkPZ5CI56Fjs.writeDebug.call(void 0,
|
|
120
|
+
`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
121
|
+
);
|
|
122
|
+
await Promise.all(
|
|
123
|
+
response.Contents.map(
|
|
124
|
+
(item) => s3Client.deleteObjects({
|
|
125
|
+
Bucket: options.bucketId,
|
|
126
|
+
Delete: {
|
|
127
|
+
Objects: [
|
|
128
|
+
{
|
|
129
|
+
Key: item.Key
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
Quiet: false
|
|
108
133
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
})));
|
|
134
|
+
})
|
|
135
|
+
)
|
|
136
|
+
);
|
|
113
137
|
} else {
|
|
114
|
-
|
|
138
|
+
_chunkPZ5CI56Fjs.writeDebug.call(void 0,
|
|
139
|
+
`No existing items to delete in the component registry path ${projectPath}`
|
|
140
|
+
);
|
|
115
141
|
}
|
|
116
142
|
} else {
|
|
117
|
-
|
|
143
|
+
_chunkPZ5CI56Fjs.writeWarning.call(void 0, "[Dry run]: skipping upload to the Cyclone Registry.");
|
|
118
144
|
}
|
|
119
145
|
const meta = {
|
|
120
146
|
name: context.projectName,
|
|
@@ -124,22 +150,47 @@ async function runExecutor(options, context) {
|
|
|
124
150
|
tags: projectDetails.content.keywords,
|
|
125
151
|
dependencies,
|
|
126
152
|
devDependencies: null,
|
|
127
|
-
internalDependencies: internalDependencies.filter(
|
|
153
|
+
internalDependencies: internalDependencies.filter(
|
|
154
|
+
(projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
|
|
155
|
+
).map((dep) => dep.name)
|
|
128
156
|
};
|
|
129
157
|
if (projectDetails.type === "package.json") {
|
|
130
158
|
meta.devDependencies = projectDetails.content.devDependencies;
|
|
131
159
|
}
|
|
132
160
|
const metaJson = JSON.stringify(meta);
|
|
133
|
-
|
|
161
|
+
_chunkPZ5CI56Fjs.writeInfo.call(void 0, `Generating meta.json file:
|
|
134
162
|
${metaJson}`);
|
|
135
|
-
await
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
await _chunkRIUVF72Kjs.r2UploadFile.call(void 0,
|
|
164
|
+
s3Client,
|
|
165
|
+
options.bucketId,
|
|
166
|
+
projectPath,
|
|
167
|
+
"meta.json",
|
|
168
|
+
version,
|
|
169
|
+
metaJson,
|
|
170
|
+
"application/json",
|
|
171
|
+
isDryRun
|
|
172
|
+
);
|
|
173
|
+
await Promise.all(
|
|
174
|
+
files.map((file) => {
|
|
175
|
+
const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
|
|
176
|
+
return _promises.readFile.call(void 0, file, { encoding: "utf8" }).then(
|
|
177
|
+
(fileContent) => _chunkRIUVF72Kjs.r2UploadFile.call(void 0,
|
|
178
|
+
s3Client,
|
|
179
|
+
options.bucketId,
|
|
180
|
+
projectPath,
|
|
181
|
+
fileName,
|
|
182
|
+
version,
|
|
183
|
+
fileContent,
|
|
184
|
+
"text/plain",
|
|
185
|
+
isDryRun
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
_chunkPZ5CI56Fjs.writeSuccess.call(void 0,
|
|
191
|
+
`Successfully uploaded the ${projectName} component to the Cyclone Registry`,
|
|
192
|
+
config
|
|
193
|
+
);
|
|
143
194
|
return {
|
|
144
195
|
success: true
|
|
145
196
|
};
|
|
@@ -152,7 +203,6 @@ ${metaJson}`);
|
|
|
152
203
|
};
|
|
153
204
|
}
|
|
154
205
|
}
|
|
155
|
-
_chunkJ5SB6L2Ljs.__name.call(void 0, runExecutor, "runExecutor");
|
|
156
206
|
|
|
157
207
|
|
|
158
208
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
-
var
|
|
3
|
+
var _chunk6XDOBG77js = require('./chunk-6XDOBG77.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var _chunkJ5SB6L2Ljs = require('./chunk-J5SB6L2L.js');
|
|
6
|
+
var _chunkMCKGQKYUjs = require('./chunk-MCKGQKYU.js');
|
|
8
7
|
|
|
9
8
|
// src/executors/cloudflare-publish/executor.ts
|
|
10
9
|
var _devkit = require('@nx/devkit');
|
|
@@ -14,15 +13,18 @@ async function runExecutor(options, context) {
|
|
|
14
13
|
if (!context.projectName) {
|
|
15
14
|
throw new Error("The executor requires a projectName.");
|
|
16
15
|
}
|
|
17
|
-
console.info(
|
|
16
|
+
console.info(
|
|
17
|
+
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
18
|
+
);
|
|
18
19
|
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])) {
|
|
19
20
|
throw new Error("The executor requires projectsConfigurations.");
|
|
20
21
|
}
|
|
21
|
-
const packageRoot = _devkit.joinPathFragments.call(void 0,
|
|
22
|
+
const packageRoot = _devkit.joinPathFragments.call(void 0,
|
|
23
|
+
context.root,
|
|
24
|
+
_optionalChain([context, 'access', _7 => _7.projectsConfigurations, 'access', _8 => _8.projects, 'access', _9 => _9[context.projectName], 'optionalAccess', _10 => _10.root])
|
|
25
|
+
);
|
|
22
26
|
try {
|
|
23
|
-
const args =
|
|
24
|
-
...options
|
|
25
|
-
});
|
|
27
|
+
const args = _chunk6XDOBG77js.createCliOptions.call(void 0, { ...options });
|
|
26
28
|
if (isDryRun) {
|
|
27
29
|
args.push("--dry-run");
|
|
28
30
|
}
|
|
@@ -31,10 +33,7 @@ async function runExecutor(options, context) {
|
|
|
31
33
|
console.log("");
|
|
32
34
|
let proc;
|
|
33
35
|
try {
|
|
34
|
-
_child_process.fork.call(void 0,
|
|
35
|
-
"deploy",
|
|
36
|
-
...args
|
|
37
|
-
], {
|
|
36
|
+
_child_process.fork.call(void 0, _chunkMCKGQKYUjs.__require.resolve("wrangler/bin/wrangler"), ["deploy", ...args], {
|
|
38
37
|
env: {
|
|
39
38
|
CLOUDFLARE_ACCOUNT_ID: process.env.STORM_BOT_CLOUDFLARE_ACCOUNT,
|
|
40
39
|
CLOUDFLARE_API_TOKEN: process.env.STORM_BOT_CLOUDFLARE_TOKEN,
|
|
@@ -43,16 +42,13 @@ async function runExecutor(options, context) {
|
|
|
43
42
|
FORCE_COLOR: "true"
|
|
44
43
|
},
|
|
45
44
|
cwd: packageRoot,
|
|
46
|
-
stdio: [
|
|
47
|
-
"pipe",
|
|
48
|
-
"pipe",
|
|
49
|
-
"pipe",
|
|
50
|
-
"ipc"
|
|
51
|
-
]
|
|
45
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"]
|
|
52
46
|
});
|
|
53
47
|
} catch (e) {
|
|
54
48
|
console.error(e);
|
|
55
|
-
throw new Error(
|
|
49
|
+
throw new Error(
|
|
50
|
+
"Unable to run Wrangler. Please ensure Wrangler is installed."
|
|
51
|
+
);
|
|
56
52
|
}
|
|
57
53
|
_optionalChain([proc, 'optionalAccess', _11 => _11.stdout, 'optionalAccess', _12 => _12.on, 'call', _13 => _13("data", (message) => {
|
|
58
54
|
process.stdout.write(message);
|
|
@@ -64,13 +60,13 @@ async function runExecutor(options, context) {
|
|
|
64
60
|
_optionalChain([proc, 'optionalAccess', _17 => _17.on, 'call', _18 => _18("close", (code) => {
|
|
65
61
|
console.log("");
|
|
66
62
|
if (isDryRun) {
|
|
67
|
-
console.log(
|
|
63
|
+
console.log(
|
|
64
|
+
"Would publish to Cloudflare Workers Registry, but [dry-run] was set"
|
|
65
|
+
);
|
|
68
66
|
} else {
|
|
69
67
|
console.log("Published to Cloudflare Workers Registry");
|
|
70
68
|
}
|
|
71
|
-
return resolve({
|
|
72
|
-
success: code === 0
|
|
73
|
-
});
|
|
69
|
+
return resolve({ success: code === 0 });
|
|
74
70
|
})]);
|
|
75
71
|
});
|
|
76
72
|
} catch (error) {
|
|
@@ -82,7 +78,6 @@ async function runExecutor(options, context) {
|
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
|
-
_chunkJ5SB6L2Ljs.__name.call(void 0, runExecutor, "runExecutor");
|
|
86
81
|
|
|
87
82
|
|
|
88
83
|
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getInternalDependencies,
|
|
3
3
|
r2UploadFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FABNT5TZ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
createCliOptions,
|
|
7
7
|
getPackageInfo
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-L4WFYC7K.mjs";
|
|
9
9
|
import {
|
|
10
10
|
getConfig
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GPAI4NHQ.mjs";
|
|
12
12
|
import {
|
|
13
13
|
findWorkspaceRoot,
|
|
14
14
|
writeDebug,
|
|
15
15
|
writeInfo,
|
|
16
16
|
writeSuccess,
|
|
17
17
|
writeWarning
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
__name
|
|
21
|
-
} from "./chunk-TLFPZXKG.mjs";
|
|
18
|
+
} from "./chunk-MV24QW26.mjs";
|
|
22
19
|
|
|
23
20
|
// src/executors/r2-upload-publish/executor.ts
|
|
24
21
|
import { S3 } from "@aws-sdk/client-s3";
|
|
25
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
createProjectGraphAsync,
|
|
24
|
+
joinPathFragments,
|
|
25
|
+
readCachedProjectGraph
|
|
26
|
+
} from "@nx/devkit";
|
|
26
27
|
import { glob } from "glob";
|
|
27
28
|
import { execSync } from "node:child_process";
|
|
28
29
|
import { readFile } from "node:fs/promises";
|
|
@@ -31,7 +32,9 @@ async function runExecutor(options, context) {
|
|
|
31
32
|
if (!context.projectName) {
|
|
32
33
|
throw new Error("The executor requires a projectName.");
|
|
33
34
|
}
|
|
34
|
-
console.info(
|
|
35
|
+
console.info(
|
|
36
|
+
`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`
|
|
37
|
+
);
|
|
35
38
|
if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
36
39
|
throw new Error("The executor requires projectsConfigurations.");
|
|
37
40
|
}
|
|
@@ -40,22 +43,28 @@ async function runExecutor(options, context) {
|
|
|
40
43
|
const config = await getConfig(workspaceRoot);
|
|
41
44
|
const sourceRoot = context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? workspaceRoot;
|
|
42
45
|
const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
|
|
43
|
-
const projectDetails = getPackageInfo(
|
|
46
|
+
const projectDetails = getPackageInfo(
|
|
47
|
+
context.projectsConfigurations.projects[context.projectName]
|
|
48
|
+
);
|
|
44
49
|
if (!projectDetails?.content) {
|
|
45
|
-
throw new Error(
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Could not find the project details for ${context.projectName}`
|
|
52
|
+
);
|
|
46
53
|
}
|
|
47
|
-
const args = createCliOptions({
|
|
48
|
-
...options
|
|
49
|
-
});
|
|
54
|
+
const args = createCliOptions({ ...options });
|
|
50
55
|
if (isDryRun) {
|
|
51
56
|
args.push("--dry-run");
|
|
52
57
|
}
|
|
53
58
|
const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
54
59
|
if (!options?.registry && !cloudflareAccountId) {
|
|
55
|
-
throw new Error(
|
|
60
|
+
throw new Error(
|
|
61
|
+
"The Storm Registry URL is not set in the Storm config. Please set either the `extensions.cyclone.registry` or `config.extensions.cyclone.accountId` property in the Storm config."
|
|
62
|
+
);
|
|
56
63
|
}
|
|
57
64
|
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
58
|
-
throw new Error(
|
|
65
|
+
throw new Error(
|
|
66
|
+
"The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are not set. Please set these environment variables to upload to the Cyclone Registry."
|
|
67
|
+
);
|
|
59
68
|
}
|
|
60
69
|
const endpoint = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
61
70
|
let projectGraph;
|
|
@@ -66,9 +75,13 @@ async function runExecutor(options, context) {
|
|
|
66
75
|
projectGraph = readCachedProjectGraph();
|
|
67
76
|
}
|
|
68
77
|
if (!projectGraph) {
|
|
69
|
-
throw new Error(
|
|
78
|
+
throw new Error(
|
|
79
|
+
"The executor failed because the project graph is not available. Please run the build command again."
|
|
80
|
+
);
|
|
70
81
|
}
|
|
71
|
-
writeInfo(
|
|
82
|
+
writeInfo(
|
|
83
|
+
`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`
|
|
84
|
+
);
|
|
72
85
|
const s3Client = new S3({
|
|
73
86
|
region: "auto",
|
|
74
87
|
endpoint,
|
|
@@ -83,8 +96,13 @@ async function runExecutor(options, context) {
|
|
|
83
96
|
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
84
97
|
});
|
|
85
98
|
const projectPath = `registry/${context.projectName}`;
|
|
86
|
-
const internalDependencies = await getInternalDependencies(
|
|
87
|
-
|
|
99
|
+
const internalDependencies = await getInternalDependencies(
|
|
100
|
+
context.projectName,
|
|
101
|
+
projectGraph
|
|
102
|
+
);
|
|
103
|
+
const dependencies = internalDependencies.filter(
|
|
104
|
+
(projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")
|
|
105
|
+
).reduce((ret, dep) => {
|
|
88
106
|
if (!ret[dep.name]) {
|
|
89
107
|
ret[dep.name] = "latest";
|
|
90
108
|
}
|
|
@@ -98,20 +116,28 @@ async function runExecutor(options, context) {
|
|
|
98
116
|
Prefix: projectPath
|
|
99
117
|
});
|
|
100
118
|
if (response?.Contents && response.Contents.length > 0) {
|
|
101
|
-
writeDebug(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
writeDebug(
|
|
120
|
+
`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`
|
|
121
|
+
);
|
|
122
|
+
await Promise.all(
|
|
123
|
+
response.Contents.map(
|
|
124
|
+
(item) => s3Client.deleteObjects({
|
|
125
|
+
Bucket: options.bucketId,
|
|
126
|
+
Delete: {
|
|
127
|
+
Objects: [
|
|
128
|
+
{
|
|
129
|
+
Key: item.Key
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
Quiet: false
|
|
108
133
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
})));
|
|
134
|
+
})
|
|
135
|
+
)
|
|
136
|
+
);
|
|
113
137
|
} else {
|
|
114
|
-
writeDebug(
|
|
138
|
+
writeDebug(
|
|
139
|
+
`No existing items to delete in the component registry path ${projectPath}`
|
|
140
|
+
);
|
|
115
141
|
}
|
|
116
142
|
} else {
|
|
117
143
|
writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
|
|
@@ -124,7 +150,9 @@ async function runExecutor(options, context) {
|
|
|
124
150
|
tags: projectDetails.content.keywords,
|
|
125
151
|
dependencies,
|
|
126
152
|
devDependencies: null,
|
|
127
|
-
internalDependencies: internalDependencies.filter(
|
|
153
|
+
internalDependencies: internalDependencies.filter(
|
|
154
|
+
(projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")
|
|
155
|
+
).map((dep) => dep.name)
|
|
128
156
|
};
|
|
129
157
|
if (projectDetails.type === "package.json") {
|
|
130
158
|
meta.devDependencies = projectDetails.content.devDependencies;
|
|
@@ -132,14 +160,37 @@ async function runExecutor(options, context) {
|
|
|
132
160
|
const metaJson = JSON.stringify(meta);
|
|
133
161
|
writeInfo(`Generating meta.json file:
|
|
134
162
|
${metaJson}`);
|
|
135
|
-
await r2UploadFile(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
await r2UploadFile(
|
|
164
|
+
s3Client,
|
|
165
|
+
options.bucketId,
|
|
166
|
+
projectPath,
|
|
167
|
+
"meta.json",
|
|
168
|
+
version,
|
|
169
|
+
metaJson,
|
|
170
|
+
"application/json",
|
|
171
|
+
isDryRun
|
|
172
|
+
);
|
|
173
|
+
await Promise.all(
|
|
174
|
+
files.map((file) => {
|
|
175
|
+
const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
|
|
176
|
+
return readFile(file, { encoding: "utf8" }).then(
|
|
177
|
+
(fileContent) => r2UploadFile(
|
|
178
|
+
s3Client,
|
|
179
|
+
options.bucketId,
|
|
180
|
+
projectPath,
|
|
181
|
+
fileName,
|
|
182
|
+
version,
|
|
183
|
+
fileContent,
|
|
184
|
+
"text/plain",
|
|
185
|
+
isDryRun
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
writeSuccess(
|
|
191
|
+
`Successfully uploaded the ${projectName} component to the Cyclone Registry`,
|
|
192
|
+
config
|
|
193
|
+
);
|
|
143
194
|
return {
|
|
144
195
|
success: true
|
|
145
196
|
};
|
|
@@ -152,7 +203,6 @@ ${metaJson}`);
|
|
|
152
203
|
};
|
|
153
204
|
}
|
|
154
205
|
}
|
|
155
|
-
__name(runExecutor, "runExecutor");
|
|
156
206
|
|
|
157
207
|
export {
|
|
158
208
|
runExecutor
|