@vexblocks/cli 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +28 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29,6 +29,11 @@ var PACKAGE_NAMES = {
|
|
|
29
29
|
types: "Type Generator"
|
|
30
30
|
};
|
|
31
31
|
var MANAGED_PACKAGES = ["cms", "shared", "types"];
|
|
32
|
+
var PROTECTED_FILES = [
|
|
33
|
+
"packages/backend/vexblocks.config.ts",
|
|
34
|
+
"packages/backend/.env",
|
|
35
|
+
"packages/backend/.env.local"
|
|
36
|
+
];
|
|
32
37
|
var PACKAGE_DEPENDENCIES = {
|
|
33
38
|
cms: ["backend", "shared"],
|
|
34
39
|
backend: [],
|
|
@@ -110,7 +115,10 @@ async function fetchFile(filePath) {
|
|
|
110
115
|
}
|
|
111
116
|
return response.text();
|
|
112
117
|
}
|
|
113
|
-
async function downloadFile(remotePath, localPath) {
|
|
118
|
+
async function downloadFile(remotePath, localPath, options) {
|
|
119
|
+
if (options?.skipIfExists && await fs2.pathExists(localPath)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
114
122
|
const url = `${GITHUB_RAW_URL}/${remotePath}`;
|
|
115
123
|
const response = await fetch(url);
|
|
116
124
|
if (!response.ok) {
|
|
@@ -138,8 +146,13 @@ async function downloadAndExtractPackage(packagePath, targetDir, onProgress) {
|
|
|
138
146
|
for (const file of files) {
|
|
139
147
|
const relativePath = file.path.slice(packagePath.length + 1);
|
|
140
148
|
const localPath = path2.join(targetDir, relativePath);
|
|
149
|
+
const isProtectedFile = PROTECTED_FILES.some(
|
|
150
|
+
(protectedPath) => file.path.endsWith(protectedPath)
|
|
151
|
+
);
|
|
141
152
|
onProgress?.(relativePath);
|
|
142
|
-
await downloadFile(file.path, localPath
|
|
153
|
+
await downloadFile(file.path, localPath, {
|
|
154
|
+
skipIfExists: isProtectedFile
|
|
155
|
+
});
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
158
|
async function getPackageFiles(packagePath) {
|
|
@@ -586,7 +599,9 @@ async function diffCommand(packageArg, options) {
|
|
|
586
599
|
logger.title("\u{1F50D} VexBlocks Diff");
|
|
587
600
|
const manifest = await readManifest(cwd);
|
|
588
601
|
if (!manifest) {
|
|
589
|
-
logger.error(
|
|
602
|
+
logger.error(
|
|
603
|
+
"No vexblocks.json found. Run `npx @vexblocks/cli init` first."
|
|
604
|
+
);
|
|
590
605
|
process.exit(1);
|
|
591
606
|
}
|
|
592
607
|
const installedPackages = Object.keys(manifest.packages);
|
|
@@ -822,7 +837,7 @@ async function createNewProject(cwd, options) {
|
|
|
822
837
|
await fs6.ensureDir(path6.join(projectDir, "packages"));
|
|
823
838
|
const packageJson = {
|
|
824
839
|
name: projectName,
|
|
825
|
-
version: "0.
|
|
840
|
+
version: "0.2.0",
|
|
826
841
|
private: true,
|
|
827
842
|
packageManager: "pnpm@9.15.0",
|
|
828
843
|
workspaces: ["apps/*", "packages/*"],
|
|
@@ -981,7 +996,9 @@ async function initializeExisting(cwd, _options) {
|
|
|
981
996
|
`1. ${pc4.cyan("npx @vexblocks/cli add all")} - Add all CMS packages`,
|
|
982
997
|
"2. Configure your environment variables",
|
|
983
998
|
`3. ${pc4.cyan(`${packageManager} install`)}`,
|
|
984
|
-
`4. ${pc4.cyan(
|
|
999
|
+
`4. ${pc4.cyan(
|
|
1000
|
+
`${packageManager === "npm" ? "npm run" : packageManager} dev`
|
|
1001
|
+
)}`
|
|
985
1002
|
]);
|
|
986
1003
|
} catch (error) {
|
|
987
1004
|
spinner.fail("Failed to initialize");
|
|
@@ -1000,7 +1017,9 @@ async function upgradeCommand(packages, options) {
|
|
|
1000
1017
|
logger.title("\u2B06\uFE0F Upgrade VexBlocks Packages");
|
|
1001
1018
|
const manifest = await readManifest(cwd);
|
|
1002
1019
|
if (!manifest) {
|
|
1003
|
-
logger.error(
|
|
1020
|
+
logger.error(
|
|
1021
|
+
"No vexblocks.json found. Run `npx @vexblocks/cli init` first."
|
|
1022
|
+
);
|
|
1004
1023
|
process.exit(1);
|
|
1005
1024
|
}
|
|
1006
1025
|
const spinner = ora4("Checking for updates...").start();
|
|
@@ -1008,7 +1027,9 @@ async function upgradeCommand(packages, options) {
|
|
|
1008
1027
|
spinner.stop();
|
|
1009
1028
|
const installedPackages = Object.keys(manifest.packages);
|
|
1010
1029
|
if (installedPackages.length === 0) {
|
|
1011
|
-
logger.info(
|
|
1030
|
+
logger.info(
|
|
1031
|
+
"No packages installed. Run `npx @vexblocks/cli add <package>` first."
|
|
1032
|
+
);
|
|
1012
1033
|
return;
|
|
1013
1034
|
}
|
|
1014
1035
|
let packagesToUpgrade;
|