@varlet/cli 2.19.0-alpha.1699555536291 → 2.19.0-alpha.1700121139736

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.
@@ -14,6 +14,7 @@ export declare function withSiteConfigNamespace(styleVars: Record<string, any>):
14
14
  export declare function watchPlatform(cb: (platform: string) => void): void;
15
15
  export declare function useRouteListener(cb: () => void): void;
16
16
  export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
17
+ export declare function getSiteStyleVars(theme: Theme): StyleVars;
17
18
  export declare function setColorScheme(theme: Theme): void;
18
19
  export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
19
20
  export { AppType, StyleProvider };
@@ -72,6 +72,9 @@ export function watchDarkMode(dark, cb) {
72
72
  cb?.(theme);
73
73
  });
74
74
  }
75
+ export function getSiteStyleVars(theme) {
76
+ return withSiteConfigNamespace(get(config, theme, {}));
77
+ }
75
78
  export function setColorScheme(theme) {
76
79
  document.documentElement.style.setProperty('color-scheme', theme === 'darkTheme' ? 'dark' : 'light');
77
80
  }
package/lib/node/bin.js CHANGED
@@ -113,7 +113,7 @@ program
113
113
  .option('-f --file <file>', 'Changelog filename')
114
114
  .description('Generate changelog')
115
115
  .action(async (options) => {
116
- const { changelog } = await import('./commands/changelog.js');
116
+ const { changelog } = await import('@varlet/release');
117
117
  return changelog(options);
118
118
  });
119
119
  program
@@ -121,7 +121,7 @@ program
121
121
  .option('-r --remote <remote>', 'Remote name')
122
122
  .description('Release all packages and generate changelogs')
123
123
  .action(async (options) => {
124
- const { release } = await import('./commands/release.js');
124
+ const { release } = await import('@varlet/release');
125
125
  return release(options);
126
126
  });
127
127
  program
@@ -1,5 +1,5 @@
1
1
  export { defineConfig } from './config/varlet.config.js';
2
- export * from './commands/release.js';
2
+ export * from '@varlet/release';
3
3
  export * from './commands/dev.js';
4
4
  export * from './commands/build.js';
5
5
  export * from './commands/compile.js';
@@ -8,7 +8,6 @@ export * from './commands/gen.js';
8
8
  export * from './commands/test.js';
9
9
  export * from './commands/create.js';
10
10
  export * from './commands/lint.js';
11
- export * from './commands/changelog.js';
12
11
  export * from './commands/preview.js';
13
12
  export * from './commands/vite.js';
14
13
  export * from './commands/extension.js';
package/lib/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { defineConfig } from './config/varlet.config.js';
2
- export * from './commands/release.js';
2
+ export * from '@varlet/release';
3
3
  export * from './commands/dev.js';
4
4
  export * from './commands/build.js';
5
5
  export * from './commands/compile.js';
@@ -8,7 +8,6 @@ export * from './commands/gen.js';
8
8
  export * from './commands/test.js';
9
9
  export * from './commands/create.js';
10
10
  export * from './commands/lint.js';
11
- export * from './commands/changelog.js';
12
11
  export * from './commands/preview.js';
13
12
  export * from './commands/vite.js';
14
13
  export * from './commands/extension.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.19.0-alpha.1699555536291",
3
+ "version": "2.19.0-alpha.1700121139736",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -34,6 +34,7 @@
34
34
  "url": "https://github.com/varletjs/varlet/issues"
35
35
  },
36
36
  "dependencies": {
37
+ "@varlet/release": "0.0.1",
37
38
  "@babel/core": "^7.22.5",
38
39
  "@babel/preset-typescript": "^7.22.5",
39
40
  "@vitejs/plugin-vue": "4.2.3",
@@ -64,8 +65,8 @@
64
65
  "vite": "4.3.5",
65
66
  "vue": "3.3.4",
66
67
  "webfont": "^9.0.0",
67
- "@varlet/shared": "2.19.0-alpha.1699555536291",
68
- "@varlet/vite-plugins": "2.19.0-alpha.1699555536291"
68
+ "@varlet/shared": "2.19.0-alpha.1700121139736",
69
+ "@varlet/vite-plugins": "2.19.0-alpha.1700121139736"
69
70
  },
70
71
  "devDependencies": {
71
72
  "@types/babel__core": "^7.20.1",
@@ -80,9 +81,9 @@
80
81
  "@types/semver": "^7.3.9",
81
82
  "@types/sharp": "0.31.1",
82
83
  "rimraf": "^5.0.1",
83
- "@varlet/icons": "2.19.0-alpha.1699555536291",
84
- "@varlet/touch-emulator": "2.19.0-alpha.1699555536291",
85
- "@varlet/ui": "2.19.0-alpha.1699555536291"
84
+ "@varlet/ui": "2.19.0-alpha.1700121139736",
85
+ "@varlet/icons": "2.19.0-alpha.1700121139736",
86
+ "@varlet/touch-emulator": "2.19.0-alpha.1700121139736"
86
87
  },
87
88
  "peerDependencies": {
88
89
  "@vue/runtime-core": "3.3.4",
@@ -95,9 +96,9 @@
95
96
  "lodash-es": "^4.17.21",
96
97
  "vue": "3.3.4",
97
98
  "vue-router": "4.2.0",
98
- "@varlet/icons": "2.19.0-alpha.1699555536291",
99
- "@varlet/touch-emulator": "2.19.0-alpha.1699555536291",
100
- "@varlet/ui": "2.19.0-alpha.1699555536291"
99
+ "@varlet/ui": "2.19.0-alpha.1700121139736",
100
+ "@varlet/icons": "2.19.0-alpha.1700121139736",
101
+ "@varlet/touch-emulator": "2.19.0-alpha.1700121139736"
101
102
  },
102
103
  "scripts": {
103
104
  "dev": "tsc --watch",
@@ -1,5 +0,0 @@
1
- export interface ChangelogCommandOptions {
2
- file?: string;
3
- releaseCount?: number;
4
- }
5
- export declare function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>;
@@ -1,20 +0,0 @@
1
- import conventionalChangelog from 'conventional-changelog';
2
- import fse from 'fs-extra';
3
- import { createSpinner } from 'nanospinner';
4
- import { resolve as resolvePath } from 'path';
5
- import { CWD } from '../shared/constant.js';
6
- const { createWriteStream } = fse;
7
- export function changelog({ releaseCount = 0, file = 'CHANGELOG.md' } = {}) {
8
- const s = createSpinner('Generating changelog').start();
9
- return new Promise((resolve) => {
10
- conventionalChangelog({
11
- preset: 'angular',
12
- releaseCount,
13
- })
14
- .pipe(createWriteStream(resolvePath(CWD, file)))
15
- .on('close', () => {
16
- s.success({ text: 'Changelog generated success!' });
17
- resolve();
18
- });
19
- });
20
- }
@@ -1,5 +0,0 @@
1
- export interface ReleaseCommandOptions {
2
- remote?: string;
3
- task?(): Promise<void>;
4
- }
5
- export declare function release(options: ReleaseCommandOptions): Promise<void>;
@@ -1,149 +0,0 @@
1
- import { createSpinner } from 'nanospinner';
2
- import fse from 'fs-extra';
3
- import execa from 'execa';
4
- import logger from '../shared/logger.js';
5
- import semver from 'semver';
6
- import glob from 'glob';
7
- import inquirer from 'inquirer';
8
- import { CWD } from '../shared/constant.js';
9
- import { resolve } from 'path';
10
- import { changelog } from './changelog.js';
11
- import { getVersion } from '../shared/fsUtils.js';
12
- const { writeFileSync, readJSONSync } = fse;
13
- const { prompt } = inquirer;
14
- const releaseTypes = ['premajor', 'preminor', 'prepatch', 'major', 'minor', 'patch'];
15
- async function isWorktreeEmpty() {
16
- const ret = await execa('git', ['status', '--porcelain']);
17
- return !ret.stdout;
18
- }
19
- async function publish(preRelease) {
20
- const s = createSpinner('Publishing all packages').start();
21
- const args = ['-r', 'publish', '--no-git-checks', '--access', 'public'];
22
- preRelease && args.push('--tag', 'alpha');
23
- const ret = await execa('pnpm', args);
24
- if (ret.stderr && ret.stderr.includes('npm ERR!')) {
25
- throw new Error('\n' + ret.stderr);
26
- }
27
- else {
28
- s.success({ text: 'Publish all packages successfully' });
29
- ret.stdout && logger.info(ret.stdout);
30
- }
31
- }
32
- async function pushGit(version, remote = 'origin') {
33
- const s = createSpinner('Pushing to remote git repository').start();
34
- await execa('git', ['add', '.']);
35
- await execa('git', ['commit', '-m', `v${version}`]);
36
- await execa('git', ['tag', `v${version}`]);
37
- await execa('git', ['push', remote, `v${version}`]);
38
- const ret = await execa('git', ['push']);
39
- s.success({ text: 'Push remote repository successfully' });
40
- ret.stdout && logger.info(ret.stdout);
41
- }
42
- function updateVersion(version) {
43
- const packageJsons = glob.sync('packages/*/package.json');
44
- packageJsons.push('package.json');
45
- packageJsons.forEach((path) => {
46
- const file = resolve(CWD, path);
47
- const config = readJSONSync(file);
48
- config.version = version;
49
- writeFileSync(file, JSON.stringify(config, null, 2));
50
- });
51
- }
52
- async function confirmRegistry() {
53
- const registry = (await execa('npm', ['config', 'get', 'registry'])).stdout;
54
- const name = 'Registry confirm';
55
- const ret = await prompt([
56
- {
57
- name,
58
- type: 'confirm',
59
- message: `Current registry is: ${registry}`,
60
- },
61
- ]);
62
- return ret[name];
63
- }
64
- async function confirmVersion(currentVersion, expectVersion) {
65
- const name = 'Version confirm';
66
- const ret = await prompt([
67
- {
68
- name,
69
- type: 'confirm',
70
- message: `All packages version ${currentVersion} -> ${expectVersion}:`,
71
- },
72
- ]);
73
- return ret[name];
74
- }
75
- async function confirmRefs(remote = 'origin') {
76
- const { stdout } = await execa('git', ['remote', '-v']);
77
- const reg = new RegExp(`${remote}\t(.*) \\(push`);
78
- const repo = stdout.match(reg)?.[1];
79
- const { stdout: branch } = await execa('git', ['branch', '--show-current']);
80
- const name = 'Refs confirm';
81
- const ret = await prompt([
82
- {
83
- name,
84
- type: 'confirm',
85
- message: `Current refs ${repo}:refs/for/${branch}`,
86
- },
87
- ]);
88
- return ret[name];
89
- }
90
- async function getReleaseType() {
91
- const name = 'Please select release type';
92
- const ret = await prompt([
93
- {
94
- name,
95
- type: 'list',
96
- choices: releaseTypes,
97
- },
98
- ]);
99
- return ret[name];
100
- }
101
- export async function release(options) {
102
- try {
103
- const currentVersion = getVersion();
104
- if (!currentVersion) {
105
- logger.error('Your package is missing the version field');
106
- return;
107
- }
108
- if (!(await isWorktreeEmpty())) {
109
- logger.error('Git worktree is not empty, please commit changed');
110
- return;
111
- }
112
- if (!(await confirmRefs(options.remote))) {
113
- return;
114
- }
115
- if (!(await confirmRegistry())) {
116
- return;
117
- }
118
- const type = await getReleaseType();
119
- const isPreRelease = type.startsWith('pre');
120
- let expectVersion = semver.inc(currentVersion, type, `alpha.${Date.now()}`);
121
- expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
122
- if (!(await confirmVersion(currentVersion, expectVersion))) {
123
- return;
124
- }
125
- updateVersion(expectVersion);
126
- if (options.task) {
127
- await options.task();
128
- }
129
- await publish(isPreRelease);
130
- if (!isPreRelease) {
131
- await changelog();
132
- await pushGit(expectVersion, options.remote);
133
- }
134
- logger.success(`Release version ${expectVersion} successfully!`);
135
- if (isPreRelease) {
136
- try {
137
- await execa('git', ['restore', '**/package.json']);
138
- await execa('git', ['restore', 'package.json']);
139
- }
140
- catch {
141
- logger.error('Restore package.json has failed, please restore manually');
142
- }
143
- }
144
- }
145
- catch (error) {
146
- logger.error(error.toString());
147
- process.exit(1);
148
- }
149
- }