@storm-software/cloudflare-tools 0.48.0 → 0.49.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 +10 -0
- package/dist/chunk-3J7KBHMJ.mjs +0 -0
- package/dist/chunk-7Z5PILRU.mjs +0 -0
- package/dist/chunk-A4ZIZ2JU.mjs +228 -0
- package/dist/chunk-A7FFSBE6.mjs +26 -0
- package/dist/chunk-CVGPWUNP.js +1 -0
- package/dist/chunk-DHBG5ASJ.js +1 -0
- package/dist/chunk-I4XNMV5U.js +227 -0
- package/dist/chunk-J5SB6L2L.js +18 -0
- package/dist/chunk-JCB2DTP6.js +42 -0
- package/dist/chunk-KKOHB7JH.js +239 -0
- package/dist/chunk-MTM5OTKD.mjs +239 -0
- package/dist/chunk-NKCR3FSU.js +153 -0
- package/dist/chunk-NSLK6ZDO.mjs +603 -0
- package/dist/chunk-OARYMVO7.mjs +501 -0
- package/dist/chunk-OJNZ4PXQ.mjs +3466 -0
- package/dist/chunk-QEWY5YJA.mjs +89 -0
- package/dist/chunk-R7AIVBS7.js +89 -0
- package/dist/chunk-RCE3CC76.js +603 -0
- package/dist/chunk-VPT6GF3S.mjs +153 -0
- package/dist/chunk-VTHBMY4B.js +133 -0
- package/dist/chunk-VYOULWAK.mjs +42 -0
- package/dist/chunk-XO66D74Z.js +1 -0
- package/dist/chunk-XU6MTFCV.mjs +133 -0
- package/dist/chunk-YE4FHRXJ.js +501 -0
- package/dist/chunk-YSCEY447.mjs +0 -0
- package/dist/chunk-Z46UO4N7.js +3465 -0
- package/dist/executors.d.mts +2 -0
- package/dist/executors.d.ts +2 -0
- package/dist/executors.js +9 -0
- package/dist/executors.mjs +9 -0
- package/dist/generator-DJ1RuHyR.d.mts +14 -0
- package/dist/generator-DJ1RuHyR.d.ts +14 -0
- package/dist/generator-DW-9W9Fk.d.mts +22 -0
- package/dist/generator-DW-9W9Fk.d.ts +22 -0
- package/dist/generators.d.mts +4 -0
- package/dist/generators.d.ts +4 -0
- package/dist/generators.js +18 -0
- package/dist/generators.mjs +18 -0
- package/dist/index.d.mts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +151 -0
- package/dist/index.mjs +151 -0
- package/dist/schema.d-DgA16PUG.d.mts +24 -0
- package/dist/schema.d-DgA16PUG.d.ts +24 -0
- package/dist/schema.d-oSirXiCO.d.mts +11 -0
- package/dist/schema.d-oSirXiCO.d.ts +11 -0
- package/dist/src/executors/cloudflare-publish/executor.d.mts +8 -0
- package/dist/src/executors/cloudflare-publish/executor.d.ts +8 -0
- package/dist/src/executors/cloudflare-publish/executor.js +11 -0
- package/dist/src/executors/cloudflare-publish/executor.mjs +11 -0
- package/dist/src/executors/r2-upload-publish/executor.d.mts +8 -0
- package/dist/src/executors/r2-upload-publish/executor.d.ts +8 -0
- package/dist/src/executors/r2-upload-publish/executor.js +11 -0
- package/dist/src/executors/r2-upload-publish/executor.mjs +11 -0
- package/dist/src/executors/serve/executor.d.mts +1240 -0
- package/dist/src/executors/serve/executor.d.ts +1240 -0
- package/dist/src/executors/serve/executor.js +75 -0
- package/dist/src/executors/serve/executor.mjs +75 -0
- package/dist/src/executors/serve/schema.d.ts +1 -1
- package/dist/src/generators/init/generator.d.mts +2 -0
- package/dist/src/generators/init/generator.d.ts +2 -0
- package/dist/src/generators/init/generator.js +11 -0
- package/dist/src/generators/init/generator.mjs +11 -0
- package/dist/src/generators/worker/generator.d.mts +3 -0
- package/dist/src/generators/worker/generator.d.ts +3 -0
- package/dist/src/generators/worker/generator.js +14 -0
- package/dist/src/generators/worker/generator.mjs +14 -0
- package/dist/src/utils/index.d.mts +3 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.js +11 -0
- package/dist/src/utils/index.mjs +11 -0
- package/dist/src/utils/r2-bucket-helpers.d.mts +7 -0
- package/dist/src/utils/r2-bucket-helpers.d.ts +7 -0
- package/dist/src/utils/r2-bucket-helpers.js +10 -0
- package/dist/src/utils/r2-bucket-helpers.mjs +10 -0
- package/dist/tsup.config.d.mts +5 -0
- package/dist/tsup.config.d.ts +5 -0
- package/dist/tsup.config.js +35 -0
- package/dist/tsup.config.mjs +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInternalDependencies,
|
|
3
|
+
r2UploadFile
|
|
4
|
+
} from "./chunk-VYOULWAK.mjs";
|
|
5
|
+
import {
|
|
6
|
+
createCliOptions,
|
|
7
|
+
getPackageInfo
|
|
8
|
+
} from "./chunk-XU6MTFCV.mjs";
|
|
9
|
+
import {
|
|
10
|
+
loadStormConfig
|
|
11
|
+
} from "./chunk-OARYMVO7.mjs";
|
|
12
|
+
import {
|
|
13
|
+
findWorkspaceRoot,
|
|
14
|
+
writeDebug,
|
|
15
|
+
writeInfo,
|
|
16
|
+
writeSuccess,
|
|
17
|
+
writeWarning
|
|
18
|
+
} from "./chunk-NSLK6ZDO.mjs";
|
|
19
|
+
import {
|
|
20
|
+
__name
|
|
21
|
+
} from "./chunk-A7FFSBE6.mjs";
|
|
22
|
+
|
|
23
|
+
// src/executors/r2-upload-publish/executor.ts
|
|
24
|
+
import { S3 } from "@aws-sdk/client-s3";
|
|
25
|
+
import { joinPathFragments, readCachedProjectGraph } from "@nx/devkit";
|
|
26
|
+
import { glob } from "glob";
|
|
27
|
+
import { execSync } from "node:child_process";
|
|
28
|
+
import { readFile } from "node:fs/promises";
|
|
29
|
+
async function runExecutor(options, context) {
|
|
30
|
+
const isDryRun = process.env.NX_DRY_RUN === "true" || options.dryRun || false;
|
|
31
|
+
if (!context.projectName) {
|
|
32
|
+
throw new Error("The executor requires a projectName.");
|
|
33
|
+
}
|
|
34
|
+
console.info(`\u{1F680} Running Storm Cloudflare Publish executor on the ${context.projectName} worker`);
|
|
35
|
+
if (!context.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
36
|
+
throw new Error("The executor requires projectsConfigurations.");
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const workspaceRoot = findWorkspaceRoot();
|
|
40
|
+
const config = await loadStormConfig(workspaceRoot);
|
|
41
|
+
const sourceRoot = context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? workspaceRoot;
|
|
42
|
+
const projectName = context.projectsConfigurations.projects[context.projectName]?.name ?? context.projectName;
|
|
43
|
+
const projectDetails = getPackageInfo(context.projectsConfigurations.projects[context.projectName]);
|
|
44
|
+
if (!projectDetails?.content) {
|
|
45
|
+
throw new Error(`Could not find the project details for ${context.projectName}`);
|
|
46
|
+
}
|
|
47
|
+
const args = createCliOptions({
|
|
48
|
+
...options
|
|
49
|
+
});
|
|
50
|
+
if (isDryRun) {
|
|
51
|
+
args.push("--dry-run");
|
|
52
|
+
}
|
|
53
|
+
const cloudflareAccountId = process.env.STORM_BOT_CLOUDFLARE_ACCOUNT;
|
|
54
|
+
if (!options?.registry && !cloudflareAccountId) {
|
|
55
|
+
throw new Error("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.");
|
|
56
|
+
}
|
|
57
|
+
if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
58
|
+
throw new Error("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.");
|
|
59
|
+
}
|
|
60
|
+
const endpoint = options?.registry ? options.registry : `https://${cloudflareAccountId}.r2.cloudflarestorage.com`;
|
|
61
|
+
const projectGraph = readCachedProjectGraph();
|
|
62
|
+
if (!projectGraph) {
|
|
63
|
+
throw new Error("No project graph found in cache");
|
|
64
|
+
}
|
|
65
|
+
writeInfo(`Publishing ${context.projectName} to the Storm Registry at ${endpoint}`);
|
|
66
|
+
const s3Client = new S3({
|
|
67
|
+
region: "auto",
|
|
68
|
+
endpoint,
|
|
69
|
+
credentials: {
|
|
70
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
71
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const version = projectDetails.content?.version;
|
|
75
|
+
writeInfo(`Generated component version: ${version}`);
|
|
76
|
+
const files = await glob(joinPathFragments(sourceRoot, "**/*"), {
|
|
77
|
+
ignore: "**/{*.stories.tsx,*.stories.ts,*.spec.tsx,*.spec.ts}"
|
|
78
|
+
});
|
|
79
|
+
const projectPath = `registry/${context.projectName}`;
|
|
80
|
+
const internalDependencies = await getInternalDependencies(context.projectName, projectGraph);
|
|
81
|
+
const dependencies = internalDependencies.filter((projectNode) => !projectNode.data.tags || projectNode.data.tags.every((tag) => tag.toLowerCase() !== "component")).reduce((ret, dep) => {
|
|
82
|
+
if (!ret[dep.name]) {
|
|
83
|
+
ret[dep.name] = "latest";
|
|
84
|
+
}
|
|
85
|
+
return ret;
|
|
86
|
+
}, projectDetails.content.dependencies ?? {});
|
|
87
|
+
const release = options.tag ?? execSync("npm config get tag").toString().trim();
|
|
88
|
+
writeInfo(`Clearing out existing items in ${projectPath}`);
|
|
89
|
+
if (!isDryRun) {
|
|
90
|
+
const response = await s3Client.listObjects({
|
|
91
|
+
Bucket: options.bucketId,
|
|
92
|
+
Prefix: projectPath
|
|
93
|
+
});
|
|
94
|
+
if (response?.Contents && response.Contents.length > 0) {
|
|
95
|
+
writeDebug(`Deleting the following existing items from the component registry: ${response.Contents.map((item) => item.Key).join(", ")}`);
|
|
96
|
+
await Promise.all(response.Contents.map((item) => s3Client.deleteObjects({
|
|
97
|
+
Bucket: options.bucketId,
|
|
98
|
+
Delete: {
|
|
99
|
+
Objects: [
|
|
100
|
+
{
|
|
101
|
+
Key: item.Key
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
Quiet: false
|
|
105
|
+
}
|
|
106
|
+
})));
|
|
107
|
+
} else {
|
|
108
|
+
writeDebug(`No existing items to delete in the component registry path ${projectPath}`);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
|
|
112
|
+
}
|
|
113
|
+
const meta = {
|
|
114
|
+
name: context.projectName,
|
|
115
|
+
version,
|
|
116
|
+
release,
|
|
117
|
+
description: projectDetails.content.description,
|
|
118
|
+
tags: projectDetails.content.keywords,
|
|
119
|
+
dependencies,
|
|
120
|
+
devDependencies: null,
|
|
121
|
+
internalDependencies: internalDependencies.filter((projectNode) => projectNode.data.tags && projectNode.data.tags.some((tag) => tag.toLowerCase() === "component")).map((dep) => dep.name)
|
|
122
|
+
};
|
|
123
|
+
if (projectDetails.type === "package.json") {
|
|
124
|
+
meta.devDependencies = projectDetails.content.devDependencies;
|
|
125
|
+
}
|
|
126
|
+
const metaJson = JSON.stringify(meta);
|
|
127
|
+
writeInfo(`Generating meta.json file:
|
|
128
|
+
${metaJson}`);
|
|
129
|
+
await r2UploadFile(s3Client, options.bucketId, projectPath, "meta.json", version, metaJson, "application/json", isDryRun);
|
|
130
|
+
await Promise.all(files.map((file) => {
|
|
131
|
+
const fileName = file.replaceAll("\\", "/").replace(sourceRoot.replaceAll("\\", "/"), "");
|
|
132
|
+
return readFile(file, {
|
|
133
|
+
encoding: "utf8"
|
|
134
|
+
}).then((fileContent) => r2UploadFile(s3Client, options.bucketId, projectPath, fileName, version, fileContent, "text/plain", isDryRun));
|
|
135
|
+
}));
|
|
136
|
+
writeSuccess(`Successfully uploaded the ${projectName} component to the Cyclone Registry`, config);
|
|
137
|
+
return {
|
|
138
|
+
success: true
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error("Failed to publish to Cloudflare Workers Registry");
|
|
142
|
+
console.error(error);
|
|
143
|
+
console.log("");
|
|
144
|
+
return {
|
|
145
|
+
success: false
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
__name(runExecutor, "runExecutor");
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
runExecutor
|
|
153
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
var _chunkJ5SB6L2Ljs = require('./chunk-J5SB6L2L.js');
|
|
4
|
+
|
|
5
|
+
// ../workspace-tools/src/utils/create-cli-options.ts
|
|
6
|
+
var _devkit = require('@nx/devkit');
|
|
7
|
+
function createCliOptions(obj) {
|
|
8
|
+
const args = [];
|
|
9
|
+
for (const key in obj) {
|
|
10
|
+
const value = obj[key];
|
|
11
|
+
if (value) {
|
|
12
|
+
const arg = _devkit.names.call(void 0, key).fileName;
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
args.push(`--${arg.toLowerCase()}=${value.map((v) => v.trim()).join(",")}`);
|
|
15
|
+
} else {
|
|
16
|
+
args.push(`--${arg.toLowerCase()}=${value}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return args;
|
|
21
|
+
}
|
|
22
|
+
_chunkJ5SB6L2Ljs.__name.call(void 0, createCliOptions, "createCliOptions");
|
|
23
|
+
|
|
24
|
+
// ../workspace-tools/src/utils/package-helpers.ts
|
|
25
|
+
|
|
26
|
+
var _fs = require('fs');
|
|
27
|
+
|
|
28
|
+
// ../workspace-tools/src/utils/project-tags.ts
|
|
29
|
+
var ProjectTagConstants = {
|
|
30
|
+
Language: {
|
|
31
|
+
TAG_ID: "language",
|
|
32
|
+
TYPESCRIPT: "typescript",
|
|
33
|
+
RUST: "rust"
|
|
34
|
+
},
|
|
35
|
+
ProjectType: {
|
|
36
|
+
TAG_ID: "type",
|
|
37
|
+
LIBRARY: "library",
|
|
38
|
+
APPLICATION: "application"
|
|
39
|
+
},
|
|
40
|
+
DistStyle: {
|
|
41
|
+
TAG_ID: "dist-style",
|
|
42
|
+
NORMAL: "normal",
|
|
43
|
+
CLEAN: "clean"
|
|
44
|
+
},
|
|
45
|
+
Provider: {
|
|
46
|
+
TAG_ID: "provider"
|
|
47
|
+
},
|
|
48
|
+
Platform: {
|
|
49
|
+
TAG_ID: "platform",
|
|
50
|
+
NODE: "node",
|
|
51
|
+
BROWSER: "browser",
|
|
52
|
+
NEUTRAL: "neutral",
|
|
53
|
+
WORKER: "worker"
|
|
54
|
+
},
|
|
55
|
+
Registry: {
|
|
56
|
+
TAG_ID: "registry",
|
|
57
|
+
CARGO: "cargo",
|
|
58
|
+
NPM: "npm",
|
|
59
|
+
CONTAINER: "container",
|
|
60
|
+
CYCLONE: "cyclone"
|
|
61
|
+
},
|
|
62
|
+
Plugin: {
|
|
63
|
+
TAG_ID: "plugin"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var formatProjectTag = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (variant, value) => {
|
|
67
|
+
return `${variant}:${value}`;
|
|
68
|
+
}, "formatProjectTag");
|
|
69
|
+
var hasProjectTag = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (project, variant) => {
|
|
70
|
+
project.tags = _nullishCoalesce(project.tags, () => ( []));
|
|
71
|
+
const prefix = formatProjectTag(variant, "");
|
|
72
|
+
return project.tags.some((tag) => tag.startsWith(prefix) && tag.length > prefix.length);
|
|
73
|
+
}, "hasProjectTag");
|
|
74
|
+
var getProjectTag = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (project, variant) => {
|
|
75
|
+
if (!hasProjectTag(project, variant)) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
project.tags = _nullishCoalesce(project.tags, () => ( []));
|
|
79
|
+
const prefix = formatProjectTag(variant, "");
|
|
80
|
+
const tag = project.tags.find((tag2) => tag2.startsWith(prefix));
|
|
81
|
+
return _optionalChain([tag, 'optionalAccess', _ => _.replace, 'call', _2 => _2(prefix, "")]);
|
|
82
|
+
}, "getProjectTag");
|
|
83
|
+
var isEqualProjectTag = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (project, variant, value) => {
|
|
84
|
+
const tag = getProjectTag(project, variant);
|
|
85
|
+
return !!(tag && _optionalChain([tag, 'optionalAccess', _3 => _3.toUpperCase, 'call', _4 => _4()]) === value.toUpperCase());
|
|
86
|
+
}, "isEqualProjectTag");
|
|
87
|
+
var addProjectTag = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (project, variant, value, options = {
|
|
88
|
+
overwrite: false
|
|
89
|
+
}) => {
|
|
90
|
+
project.tags = _nullishCoalesce(project.tags, () => ( []));
|
|
91
|
+
if (options.overwrite || !hasProjectTag(project, variant)) {
|
|
92
|
+
project.tags = project.tags.filter((tag) => !tag.startsWith(formatProjectTag(variant, "")));
|
|
93
|
+
project.tags.push(formatProjectTag(variant, value));
|
|
94
|
+
}
|
|
95
|
+
}, "addProjectTag");
|
|
96
|
+
|
|
97
|
+
// ../workspace-tools/src/utils/toml.ts
|
|
98
|
+
var _jtoml = require('@ltd/j-toml'); var _jtoml2 = _interopRequireDefault(_jtoml);
|
|
99
|
+
|
|
100
|
+
function parseCargoToml(cargoString) {
|
|
101
|
+
if (!cargoString) {
|
|
102
|
+
throw new Error("Cargo.toml is empty");
|
|
103
|
+
}
|
|
104
|
+
return _jtoml2.default.parse(cargoString, {
|
|
105
|
+
x: {
|
|
106
|
+
comment: true
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
_chunkJ5SB6L2Ljs.__name.call(void 0, parseCargoToml, "parseCargoToml");
|
|
111
|
+
|
|
112
|
+
// ../workspace-tools/src/utils/package-helpers.ts
|
|
113
|
+
var getPackageInfo = /* @__PURE__ */ _chunkJ5SB6L2Ljs.__name.call(void 0, (project) => {
|
|
114
|
+
if (isEqualProjectTag(project, ProjectTagConstants.Language.TAG_ID, ProjectTagConstants.Language.RUST) && _fs.existsSync.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "Cargo.toml"))) {
|
|
115
|
+
return {
|
|
116
|
+
type: "Cargo.toml",
|
|
117
|
+
content: parseCargoToml(_devkit.joinPathFragments.call(void 0, project.root, "Cargo.toml"))
|
|
118
|
+
};
|
|
119
|
+
} else if (isEqualProjectTag(project, ProjectTagConstants.Language.TAG_ID, ProjectTagConstants.Language.TYPESCRIPT) && _fs.existsSync.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "package.json"))) {
|
|
120
|
+
return {
|
|
121
|
+
type: "package.json",
|
|
122
|
+
content: _devkit.readJsonFile.call(void 0, _devkit.joinPathFragments.call(void 0, project.root, "package.json"))
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}, "getPackageInfo");
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
exports.ProjectTagConstants = ProjectTagConstants; exports.addProjectTag = addProjectTag; exports.createCliOptions = createCliOptions; exports.getPackageInfo = getPackageInfo;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeDebug,
|
|
3
|
+
writeWarning
|
|
4
|
+
} from "./chunk-NSLK6ZDO.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__name
|
|
7
|
+
} from "./chunk-A7FFSBE6.mjs";
|
|
8
|
+
|
|
9
|
+
// src/utils/r2-bucket-helpers.ts
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
var r2UploadFile = /* @__PURE__ */ __name(async (client, bucketName, projectPath, fileName, version, fileContent, contentType = "text/plain", isDryRun = false) => {
|
|
12
|
+
const checksum = createHash("sha256").update(fileContent).digest("base64");
|
|
13
|
+
const fileKey = `${projectPath}/${fileName.startsWith("/") ? fileName.substring(1) : fileName}`;
|
|
14
|
+
writeDebug(`Uploading file: ${fileKey}`);
|
|
15
|
+
if (!isDryRun) {
|
|
16
|
+
await client.putObject({
|
|
17
|
+
Bucket: bucketName,
|
|
18
|
+
Key: fileKey,
|
|
19
|
+
Body: fileContent.replaceAll(' from "@cyclone-ui/', ' from "../'),
|
|
20
|
+
ContentType: contentType,
|
|
21
|
+
Metadata: {
|
|
22
|
+
version,
|
|
23
|
+
checksum
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
writeWarning("[Dry run]: skipping upload to the Cyclone Registry.");
|
|
28
|
+
}
|
|
29
|
+
}, "r2UploadFile");
|
|
30
|
+
var getInternalDependencies = /* @__PURE__ */ __name((projectName, graph) => {
|
|
31
|
+
const allDeps = graph.dependencies[projectName] ?? [];
|
|
32
|
+
return Array.from(allDeps.reduce((acc, node) => {
|
|
33
|
+
const found = graph.nodes[node.target];
|
|
34
|
+
if (found) acc.push(found);
|
|
35
|
+
return acc;
|
|
36
|
+
}, []));
|
|
37
|
+
}, "getInternalDependencies");
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
r2UploadFile,
|
|
41
|
+
getInternalDependencies
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-A7FFSBE6.mjs";
|
|
4
|
+
|
|
5
|
+
// ../workspace-tools/src/utils/create-cli-options.ts
|
|
6
|
+
import { names } from "@nx/devkit";
|
|
7
|
+
function createCliOptions(obj) {
|
|
8
|
+
const args = [];
|
|
9
|
+
for (const key in obj) {
|
|
10
|
+
const value = obj[key];
|
|
11
|
+
if (value) {
|
|
12
|
+
const arg = names(key).fileName;
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
args.push(`--${arg.toLowerCase()}=${value.map((v) => v.trim()).join(",")}`);
|
|
15
|
+
} else {
|
|
16
|
+
args.push(`--${arg.toLowerCase()}=${value}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return args;
|
|
21
|
+
}
|
|
22
|
+
__name(createCliOptions, "createCliOptions");
|
|
23
|
+
|
|
24
|
+
// ../workspace-tools/src/utils/package-helpers.ts
|
|
25
|
+
import { joinPathFragments, readJsonFile } from "@nx/devkit";
|
|
26
|
+
import { existsSync } from "node:fs";
|
|
27
|
+
|
|
28
|
+
// ../workspace-tools/src/utils/project-tags.ts
|
|
29
|
+
var ProjectTagConstants = {
|
|
30
|
+
Language: {
|
|
31
|
+
TAG_ID: "language",
|
|
32
|
+
TYPESCRIPT: "typescript",
|
|
33
|
+
RUST: "rust"
|
|
34
|
+
},
|
|
35
|
+
ProjectType: {
|
|
36
|
+
TAG_ID: "type",
|
|
37
|
+
LIBRARY: "library",
|
|
38
|
+
APPLICATION: "application"
|
|
39
|
+
},
|
|
40
|
+
DistStyle: {
|
|
41
|
+
TAG_ID: "dist-style",
|
|
42
|
+
NORMAL: "normal",
|
|
43
|
+
CLEAN: "clean"
|
|
44
|
+
},
|
|
45
|
+
Provider: {
|
|
46
|
+
TAG_ID: "provider"
|
|
47
|
+
},
|
|
48
|
+
Platform: {
|
|
49
|
+
TAG_ID: "platform",
|
|
50
|
+
NODE: "node",
|
|
51
|
+
BROWSER: "browser",
|
|
52
|
+
NEUTRAL: "neutral",
|
|
53
|
+
WORKER: "worker"
|
|
54
|
+
},
|
|
55
|
+
Registry: {
|
|
56
|
+
TAG_ID: "registry",
|
|
57
|
+
CARGO: "cargo",
|
|
58
|
+
NPM: "npm",
|
|
59
|
+
CONTAINER: "container",
|
|
60
|
+
CYCLONE: "cyclone"
|
|
61
|
+
},
|
|
62
|
+
Plugin: {
|
|
63
|
+
TAG_ID: "plugin"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var formatProjectTag = /* @__PURE__ */ __name((variant, value) => {
|
|
67
|
+
return `${variant}:${value}`;
|
|
68
|
+
}, "formatProjectTag");
|
|
69
|
+
var hasProjectTag = /* @__PURE__ */ __name((project, variant) => {
|
|
70
|
+
project.tags = project.tags ?? [];
|
|
71
|
+
const prefix = formatProjectTag(variant, "");
|
|
72
|
+
return project.tags.some((tag) => tag.startsWith(prefix) && tag.length > prefix.length);
|
|
73
|
+
}, "hasProjectTag");
|
|
74
|
+
var getProjectTag = /* @__PURE__ */ __name((project, variant) => {
|
|
75
|
+
if (!hasProjectTag(project, variant)) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
project.tags = project.tags ?? [];
|
|
79
|
+
const prefix = formatProjectTag(variant, "");
|
|
80
|
+
const tag = project.tags.find((tag2) => tag2.startsWith(prefix));
|
|
81
|
+
return tag?.replace(prefix, "");
|
|
82
|
+
}, "getProjectTag");
|
|
83
|
+
var isEqualProjectTag = /* @__PURE__ */ __name((project, variant, value) => {
|
|
84
|
+
const tag = getProjectTag(project, variant);
|
|
85
|
+
return !!(tag && tag?.toUpperCase() === value.toUpperCase());
|
|
86
|
+
}, "isEqualProjectTag");
|
|
87
|
+
var addProjectTag = /* @__PURE__ */ __name((project, variant, value, options = {
|
|
88
|
+
overwrite: false
|
|
89
|
+
}) => {
|
|
90
|
+
project.tags = project.tags ?? [];
|
|
91
|
+
if (options.overwrite || !hasProjectTag(project, variant)) {
|
|
92
|
+
project.tags = project.tags.filter((tag) => !tag.startsWith(formatProjectTag(variant, "")));
|
|
93
|
+
project.tags.push(formatProjectTag(variant, value));
|
|
94
|
+
}
|
|
95
|
+
}, "addProjectTag");
|
|
96
|
+
|
|
97
|
+
// ../workspace-tools/src/utils/toml.ts
|
|
98
|
+
import TOML from "@ltd/j-toml";
|
|
99
|
+
import { logger } from "@nx/devkit";
|
|
100
|
+
function parseCargoToml(cargoString) {
|
|
101
|
+
if (!cargoString) {
|
|
102
|
+
throw new Error("Cargo.toml is empty");
|
|
103
|
+
}
|
|
104
|
+
return TOML.parse(cargoString, {
|
|
105
|
+
x: {
|
|
106
|
+
comment: true
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
__name(parseCargoToml, "parseCargoToml");
|
|
111
|
+
|
|
112
|
+
// ../workspace-tools/src/utils/package-helpers.ts
|
|
113
|
+
var getPackageInfo = /* @__PURE__ */ __name((project) => {
|
|
114
|
+
if (isEqualProjectTag(project, ProjectTagConstants.Language.TAG_ID, ProjectTagConstants.Language.RUST) && existsSync(joinPathFragments(project.root, "Cargo.toml"))) {
|
|
115
|
+
return {
|
|
116
|
+
type: "Cargo.toml",
|
|
117
|
+
content: parseCargoToml(joinPathFragments(project.root, "Cargo.toml"))
|
|
118
|
+
};
|
|
119
|
+
} else if (isEqualProjectTag(project, ProjectTagConstants.Language.TAG_ID, ProjectTagConstants.Language.TYPESCRIPT) && existsSync(joinPathFragments(project.root, "package.json"))) {
|
|
120
|
+
return {
|
|
121
|
+
type: "package.json",
|
|
122
|
+
content: readJsonFile(joinPathFragments(project.root, "package.json"))
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}, "getPackageInfo");
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
ProjectTagConstants,
|
|
130
|
+
addProjectTag,
|
|
131
|
+
createCliOptions,
|
|
132
|
+
getPackageInfo
|
|
133
|
+
};
|