zuby 1.0.44 → 1.0.46
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/commands/index.js +11 -0
- package/commands/info.d.ts +2 -0
- package/commands/info.js +14 -0
- package/commands/upgrade.d.ts +3 -0
- package/commands/upgrade.js +80 -0
- package/package.json +5 -4
- package/types.d.ts +7 -0
package/commands/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import dev from './dev.js';
|
|
|
5
5
|
import build from './build.js';
|
|
6
6
|
import preview from './preview.js';
|
|
7
7
|
import init from './init.js';
|
|
8
|
+
import info from './info.js';
|
|
9
|
+
import upgrade from './upgrade.js';
|
|
8
10
|
const { name, description, version } = getZubyPackageConfig();
|
|
9
11
|
const program = new Command().name(name).description(description).version(version);
|
|
10
12
|
program
|
|
@@ -31,4 +33,13 @@ program
|
|
|
31
33
|
.command('init')
|
|
32
34
|
.description('Initializes a new Zuby project')
|
|
33
35
|
.action(async (options) => init(options));
|
|
36
|
+
program
|
|
37
|
+
.command('info')
|
|
38
|
+
.description('Prints useful information about your setup')
|
|
39
|
+
.action(async (options) => info(options));
|
|
40
|
+
program
|
|
41
|
+
.command('upgrade')
|
|
42
|
+
.description('Upgrades Zuby to the latest compatible version')
|
|
43
|
+
.option('-t, --tag <tag>', 'The tag to upgrade to (e.g. v1, v2, latest)')
|
|
44
|
+
.action(async (options) => upgrade(options));
|
|
34
45
|
program.parse(process.argv);
|
package/commands/info.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getZubyInternalConfig } from '../config.js';
|
|
2
|
+
import { getZubyPackageConfig } from '../packageConfig.js';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
export default async function info({ configFile }) {
|
|
5
|
+
const { outDir, output, plugins, customLogger: logger } = await getZubyInternalConfig(configFile);
|
|
6
|
+
const { version } = getZubyPackageConfig();
|
|
7
|
+
logger.info(`Zuby: ${version}`);
|
|
8
|
+
logger.info(`Node: ${process.version}`);
|
|
9
|
+
logger.info(`OS: ${os.type()} ${os.release()}`);
|
|
10
|
+
logger.info(`Output: ${output}`);
|
|
11
|
+
logger.info(`Output dir: ${outDir}`);
|
|
12
|
+
const pluginNames = plugins.map(plugin => plugin.name).join(', ');
|
|
13
|
+
logger.info(`Plugins: ${plugins.length ? pluginNames : 'none'}`);
|
|
14
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getZubyInternalConfig } from '../config.js';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { getZubyPackageConfig } from '../packageConfig.js';
|
|
6
|
+
import { getTitle } from '../branding.js';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
export default async function upgrade({ configFile, tag }) {
|
|
9
|
+
const { customLogger: logger } = await getZubyInternalConfig(configFile);
|
|
10
|
+
const packageJsonPath = resolve('package.json');
|
|
11
|
+
const { version: currentVersion } = getZubyPackageConfig();
|
|
12
|
+
const [currentMajor, _currentMinor, _currentPatch] = currentVersion.split('.');
|
|
13
|
+
if (!existsSync(packageJsonPath)) {
|
|
14
|
+
logger.error(`ERROR: Could not find package.json`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
18
|
+
const res = await fetch('https://registry.npmjs.org/-/package/zuby/dist-tags');
|
|
19
|
+
if (!res.ok) {
|
|
20
|
+
logger.error(`ERROR: Failed to fetch latest version from NPM.`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const tags = (await res.json());
|
|
24
|
+
const latestVersion = tags.latest;
|
|
25
|
+
const selectedVersion = tags[tag || `v${currentMajor}`] || latestVersion;
|
|
26
|
+
logger.info(getTitle(`Checking...`));
|
|
27
|
+
if (currentVersion === latestVersion) {
|
|
28
|
+
logger.info(`You are on the latest version of Zuby.js ${currentVersion}`);
|
|
29
|
+
logger.info(`Well done! 🎉`);
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
if (selectedVersion !== latestVersion) {
|
|
33
|
+
logger.info(chalk.bold(`New major version of Zuby.js is available: ${latestVersion}`));
|
|
34
|
+
logger.info(`Run 'npx zuby upgrade --tag latest' if you're prepared to upgrade to it.`);
|
|
35
|
+
logger.info(`\r\n`);
|
|
36
|
+
}
|
|
37
|
+
if (currentVersion === selectedVersion) {
|
|
38
|
+
logger.info(`You are on the latest compatible version of Zuby.js ${currentVersion}`);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
logger.info(`Upgrading Zuby.js to ${selectedVersion}`);
|
|
42
|
+
Object.keys({
|
|
43
|
+
...(packageJson.dependencies || {}),
|
|
44
|
+
...(packageJson.devDependencies || {}),
|
|
45
|
+
}).forEach(name => {
|
|
46
|
+
if (!name.match(/^zuby|@zubyjs\/(.+)$/i))
|
|
47
|
+
return;
|
|
48
|
+
if (packageJson.dependencies?.[name]) {
|
|
49
|
+
packageJson.dependencies[name] = selectedVersion;
|
|
50
|
+
}
|
|
51
|
+
if (packageJson.devDependencies?.[name]) {
|
|
52
|
+
packageJson.devDependencies[name] = selectedVersion;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
logger.info(`Writing package.json`);
|
|
56
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
57
|
+
if (installDependencies()) {
|
|
58
|
+
logger.info(`Zuby.js upgraded to ${selectedVersion}!`);
|
|
59
|
+
logger.info(`Well done! 🎉`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
logger.info(`We're done! 🎉 Now it's your turn.`);
|
|
63
|
+
logger.info(`Please run 'npm install', 'yarn install' etc.. with your favorite package manager to finish the upgrade.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function installDependencies() {
|
|
67
|
+
if (existsSync('package-lock.json')) {
|
|
68
|
+
execSync('npm install', { stdio: 'inherit' });
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
if (existsSync('yarn.lock')) {
|
|
72
|
+
execSync('yarn install', { stdio: 'inherit' });
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (existsSync('pnpm-lock.yaml')) {
|
|
76
|
+
execSync('pnpm install', { stdio: 'inherit' });
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zuby",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "Zuby.js is framework for building SPA apps using Vite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://zuby.futrou.com",
|
|
48
48
|
"keywords": [
|
|
49
|
-
"
|
|
49
|
+
"zuby",
|
|
50
|
+
"framework",
|
|
50
51
|
"vite",
|
|
51
52
|
"spa",
|
|
52
|
-
"framework",
|
|
53
53
|
"web",
|
|
54
|
-
"
|
|
54
|
+
"preact",
|
|
55
|
+
"react"
|
|
55
56
|
],
|
|
56
57
|
"engines": {
|
|
57
58
|
"node": ">=16"
|
package/types.d.ts
CHANGED
|
@@ -169,6 +169,13 @@ export interface InitCommandOptions {
|
|
|
169
169
|
*/
|
|
170
170
|
projectName?: string;
|
|
171
171
|
}
|
|
172
|
+
export interface UpgradeCommandOptions extends BaseCommandOptions {
|
|
173
|
+
/**
|
|
174
|
+
* The version tag to upgrade to.
|
|
175
|
+
* Defaults to the latest compatible version.
|
|
176
|
+
*/
|
|
177
|
+
tag?: string;
|
|
178
|
+
}
|
|
172
179
|
export declare const MODES: {
|
|
173
180
|
development: string;
|
|
174
181
|
production: string;
|