@deot/dev-cli 1.0.5 → 1.0.6
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/README.md +54 -2
- package/config/jest.config.js +13 -4
- package/dist/index.js +89 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,8 +9,60 @@
|
|
|
9
9
|
- `link`
|
|
10
10
|
- `test`
|
|
11
11
|
- `add`
|
|
12
|
-
- `release`: [与本仓库相同](
|
|
12
|
+
- `release`: [与本仓库相同](../../README.md)
|
|
13
13
|
|
|
14
14
|
## 其他
|
|
15
15
|
|
|
16
|
-
暂时不支持全局引入,一些配置项,如`tsconfig.json`, `api-extractor.json`, `jest.config.cjs` 这些依赖项目本身
|
|
16
|
+
暂时不支持全局引入,一些配置项,如`tsconfig.json`, `api-extractor.json`, `jest.config.cjs` 这些依赖项目本身
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 默认的目录参考(配置后期再考虑)
|
|
20
|
+
|
|
21
|
+
#### Monorepo
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Monorepo
|
|
25
|
+
├─ .husky
|
|
26
|
+
├─ packages
|
|
27
|
+
│ ├─ index
|
|
28
|
+
│ │ ├─ __tests__
|
|
29
|
+
│ │ ├─ src
|
|
30
|
+
│ │ ├─ api-extractor.json
|
|
31
|
+
│ │ └─ package.json
|
|
32
|
+
│ ├─ shared
|
|
33
|
+
│ │ ├─ __tests__
|
|
34
|
+
│ │ ├─ src
|
|
35
|
+
│ │ ├─ api-extractor.json
|
|
36
|
+
│ │ └─ package.json
|
|
37
|
+
│ └─ shims.d.ts
|
|
38
|
+
├─ .eslintignore
|
|
39
|
+
├─ .eslintrc.cjs
|
|
40
|
+
├─ .lintstagedrc.json
|
|
41
|
+
├─ .npmrc
|
|
42
|
+
├─ jest.config.js
|
|
43
|
+
├─ pnpm-lock.yaml
|
|
44
|
+
├─ pnpm-workspace.yaml
|
|
45
|
+
├─ tsconfig.json
|
|
46
|
+
└─ package.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Single Repo
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Single Repo
|
|
53
|
+
├─ .husky
|
|
54
|
+
├─ __tests__
|
|
55
|
+
├─ src
|
|
56
|
+
├─ .eslintignore
|
|
57
|
+
├─ .eslintrc.cjs
|
|
58
|
+
├─ .npmrc
|
|
59
|
+
├─ jest.config.js
|
|
60
|
+
├─ shims.d.ts
|
|
61
|
+
├─ api-extractor.json
|
|
62
|
+
├─ pnpm-lock.yaml
|
|
63
|
+
├─ pnpm-workspace.yaml
|
|
64
|
+
├─ tsconfig.json
|
|
65
|
+
├─ yarn.lock
|
|
66
|
+
└─ package.json
|
|
67
|
+
```
|
|
68
|
+
|
package/config/jest.config.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
const options = JSON.parse(decodeURIComponent(process.env.TEST_OPTIONS || '{}'));
|
|
2
|
-
const { packageFolderName } = options;
|
|
2
|
+
const { workspace, packageFolderName } = options;
|
|
3
|
+
const rootDir = process.cwd();
|
|
4
|
+
|
|
5
|
+
const testDirPrefix = workspace
|
|
6
|
+
? `<rootDir>/${workspace}/${packageFolderName || '*'}/__tests__`
|
|
7
|
+
: `<rootDir>/__tests__`;
|
|
8
|
+
|
|
9
|
+
const collectDirPrefix = workspace
|
|
10
|
+
? `<rootDir>/${workspace}/${packageFolderName || '*'}/src`
|
|
11
|
+
: `<rootDir>/src`;
|
|
3
12
|
|
|
4
13
|
export default {
|
|
5
14
|
preset: 'ts-jest',
|
|
@@ -22,19 +31,19 @@ export default {
|
|
|
22
31
|
// 匹配相关
|
|
23
32
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
|
24
33
|
// 匹配规则很重要
|
|
25
|
-
rootDir
|
|
34
|
+
rootDir,
|
|
26
35
|
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
|
|
27
36
|
testPathIgnorePatterns: [
|
|
28
37
|
'/node_modules/'
|
|
29
38
|
],
|
|
30
39
|
testMatch: [
|
|
31
|
-
|
|
40
|
+
`${testDirPrefix}/**.(spec|test).[jt]s?(x)`
|
|
32
41
|
],
|
|
33
42
|
|
|
34
43
|
collectCoverage: true,
|
|
35
44
|
coverageDirectory: 'coverage',
|
|
36
45
|
collectCoverageFrom: [
|
|
37
|
-
|
|
46
|
+
`${collectDirPrefix}/**/*.ts`
|
|
38
47
|
],
|
|
39
48
|
coverageThreshold: {
|
|
40
49
|
global: {
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { program } from 'commander';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import ora from 'ora';
|
|
5
|
-
import { Utils,
|
|
5
|
+
import { Utils, Logger, Shell } from '@deot/dev-shared';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { resolve } from 'node:path';
|
|
8
8
|
import fs from 'fs-extra';
|
|
@@ -61,16 +61,20 @@ class Shared {
|
|
|
61
61
|
return result.reverse();
|
|
62
62
|
};
|
|
63
63
|
static getPackageName = (packageFolderName$) => {
|
|
64
|
-
const { packageFolderName, packageName } = Shared.impl();
|
|
65
|
-
if (!
|
|
66
|
-
|
|
64
|
+
const { workspace, packageFolderName, packageName } = Shared.impl();
|
|
65
|
+
if (!workspace
|
|
66
|
+
|| !packageFolderName$
|
|
67
|
+
|| packageFolderName$ === packageFolderName) {
|
|
68
|
+
return packageName;
|
|
67
69
|
}
|
|
68
70
|
else {
|
|
69
71
|
return `${packageName}-${packageFolderName$.replace(new RegExp(`${packageName}-?`), '')}`;
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
74
|
static getPackageFolderName = (packageName$) => {
|
|
73
|
-
const { packageFolderName, packageName } = Shared.impl();
|
|
75
|
+
const { workspace, packageFolderName, packageName } = Shared.impl();
|
|
76
|
+
if (!workspace)
|
|
77
|
+
return '';
|
|
74
78
|
if (packageName$ === packageName)
|
|
75
79
|
return packageFolderName;
|
|
76
80
|
return packageName$?.replace(new RegExp(`${packageName}-?`), '');
|
|
@@ -79,12 +83,15 @@ class Shared {
|
|
|
79
83
|
if (Shared.config)
|
|
80
84
|
return Shared.config;
|
|
81
85
|
const rootPackageOptions = require$$2(`${cwd}/package.json`);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
let workspace = 'packages';
|
|
87
|
+
let isMonorepo = fs.existsSync(path.resolve(cwd, workspace));
|
|
88
|
+
workspace = isMonorepo ? workspace : '';
|
|
89
|
+
const packageFolderName = isMonorepo ? 'index' : '';
|
|
90
|
+
const packageDir = path.resolve(cwd, workspace);
|
|
91
|
+
const packageOptions = require$$2(path.resolve(packageDir, packageFolderName, 'package.json'));
|
|
85
92
|
const packageName = packageOptions.name;
|
|
86
93
|
const packageVersion = packageOptions.version;
|
|
87
|
-
const packageFolderNames = fs
|
|
94
|
+
const packageFolderNames = !isMonorepo ? [] : fs
|
|
88
95
|
.readdirSync(packageDir)
|
|
89
96
|
.reduce((pre, file) => {
|
|
90
97
|
const fullpath = path.resolve(packageDir, file);
|
|
@@ -95,12 +102,12 @@ class Shared {
|
|
|
95
102
|
}
|
|
96
103
|
return pre;
|
|
97
104
|
}, []);
|
|
98
|
-
const packageOptionsMap = packageFolderNames.reduce((pre,
|
|
99
|
-
pre[
|
|
105
|
+
const packageOptionsMap = packageFolderNames.reduce((pre, packageFolderName$) => {
|
|
106
|
+
pre[packageFolderName$] = require$$2(path.resolve(packageDir, packageFolderName$, 'package.json'));
|
|
100
107
|
return pre;
|
|
101
108
|
}, {});
|
|
102
|
-
const packageRelation = packageFolderNames.reduce((pre,
|
|
103
|
-
let packagesOptions = packageOptionsMap[
|
|
109
|
+
const packageRelation = packageFolderNames.reduce((pre, packageFolderName$) => {
|
|
110
|
+
let packagesOptions = packageOptionsMap[packageFolderName$];
|
|
104
111
|
let deps = {
|
|
105
112
|
...(packagesOptions.dependencies || {}),
|
|
106
113
|
...(packagesOptions.devDependencies || {}),
|
|
@@ -111,8 +118,10 @@ class Shared {
|
|
|
111
118
|
const normalizePackageNames = Shared.getNormalizePackage(packageRelation);
|
|
112
119
|
const normalizePackageFolderNames = normalizePackageNames
|
|
113
120
|
.map(i => i.replace(new RegExp(`${packageName}-?`), '') || packageFolderName);
|
|
121
|
+
const homepage = (rootPackageOptions.repository || packageOptions.repository || {}).url || '';
|
|
114
122
|
const config = {
|
|
115
|
-
|
|
123
|
+
workspace,
|
|
124
|
+
homepage: homepage.replace(/(.*)(https?:\/\/.*)(#|\.git)/, '$2'),
|
|
116
125
|
packageFolderName,
|
|
117
126
|
packageDir,
|
|
118
127
|
packageOptions,
|
|
@@ -130,13 +139,17 @@ class Shared {
|
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
const run$5 = (options) => Utils.autoCatch(async () => {
|
|
142
|
+
const locals = Shared.impl();
|
|
143
|
+
const { workspace, packageFolderNames } = locals;
|
|
144
|
+
if (!workspace) {
|
|
145
|
+
return Logger.log(`<link> Monorepo Supported Only.`);
|
|
146
|
+
}
|
|
133
147
|
if (typeof options.dryRun === 'undefined') {
|
|
134
148
|
options.dryRun = process.env.NODE_ENV === 'UNIT';
|
|
135
149
|
}
|
|
136
|
-
const command =
|
|
150
|
+
const command = `npx pnpm link ./${workspace}/`;
|
|
137
151
|
if (options.dryRun)
|
|
138
152
|
return Shell.spawn(`echo ${command}`);
|
|
139
|
-
const { packageFolderNames } = Shared.impl();
|
|
140
153
|
const spinner = ora(`Links ...\n`);
|
|
141
154
|
spinner.start();
|
|
142
155
|
await Promise.all(packageFolderNames.map(i => {
|
|
@@ -231,14 +244,18 @@ const getOptions$1 = async () => {
|
|
|
231
244
|
};
|
|
232
245
|
|
|
233
246
|
const run$4 = (options) => Utils.autoCatch(async () => {
|
|
247
|
+
const locals = Shared.impl();
|
|
248
|
+
const { workspace, packageDir } = locals;
|
|
249
|
+
if (!workspace) {
|
|
250
|
+
return Logger.log(`<add> Monorepo Supported Only.`);
|
|
251
|
+
}
|
|
234
252
|
if (typeof options.dryRun === 'undefined') {
|
|
235
253
|
options.dryRun = process.env.NODE_ENV === 'UNIT';
|
|
236
254
|
}
|
|
237
255
|
const { mode, dependentName, args, packageFolderName, packageName } = await getOptions$1();
|
|
238
|
-
const { packageDir } = Shared.impl();
|
|
239
256
|
let command = mode === 'dependent'
|
|
240
257
|
? `npx pnpm add --filter ${packageName} ${dependentName} ${args.join(' ')}`
|
|
241
|
-
: `npx pnpm link
|
|
258
|
+
: `npx pnpm link ./${workspace}/${packageFolderName}`;
|
|
242
259
|
if (options.dryRun)
|
|
243
260
|
return Shell.spawn(`echo "${command}"`);
|
|
244
261
|
const spinner = ora(`${command}\n`).start();
|
|
@@ -266,7 +283,7 @@ const run$4 = (options) => Utils.autoCatch(async () => {
|
|
|
266
283
|
}, null, 2));
|
|
267
284
|
fs.outputFileSync(`${dir}/${packageFolderName}/api-extractor.json`, JSON.stringify({
|
|
268
285
|
extends: "../../api-extractor.json",
|
|
269
|
-
mainEntryPointFilePath: `./dist
|
|
286
|
+
mainEntryPointFilePath: `./dist/${workspace}/${packageFolderName}/src/index.d.ts`,
|
|
270
287
|
dtsRollup: {
|
|
271
288
|
publicTrimmedFilePath: "./dist/index.d.ts"
|
|
272
289
|
}
|
|
@@ -317,10 +334,11 @@ const getOptions = async () => {
|
|
|
317
334
|
};
|
|
318
335
|
|
|
319
336
|
const run$3 = (options) => Utils.autoCatch(async () => {
|
|
337
|
+
const locals = Shared.impl();
|
|
320
338
|
if (typeof options.dryRun === 'undefined') {
|
|
321
339
|
options.dryRun = process.env.NODE_ENV === 'UNIT';
|
|
322
340
|
}
|
|
323
|
-
if (!options.packageName) {
|
|
341
|
+
if (locals.workspace && !options.packageName) {
|
|
324
342
|
const promptOptions = await getOptions();
|
|
325
343
|
options = {
|
|
326
344
|
...options,
|
|
@@ -329,8 +347,11 @@ const run$3 = (options) => Utils.autoCatch(async () => {
|
|
|
329
347
|
}
|
|
330
348
|
const { packageName, watch, dryRun } = options;
|
|
331
349
|
options.packageFolderName = Shared.getPackageFolderName(options.packageName) || options.packageFolderName;
|
|
350
|
+
options.workspace = locals.workspace;
|
|
332
351
|
if (!options.packageFolderName)
|
|
333
352
|
delete options.packageFolderName;
|
|
353
|
+
if (!options.workspace)
|
|
354
|
+
delete options.workspace;
|
|
334
355
|
delete options.packageName;
|
|
335
356
|
const command = `cross-env NODE_ENV=${process.env.NODE_ENV || 'TEST'} TEST_OPTIONS=${encodeURIComponent(JSON.stringify(options))} jest `
|
|
336
357
|
+ ([
|
|
@@ -362,6 +383,7 @@ const run$2 = (options) => Utils.autoCatch(async () => {
|
|
|
362
383
|
if (options.dryRun)
|
|
363
384
|
return Shell.spawn(`echo development`);
|
|
364
385
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
386
|
+
options.watch = true;
|
|
365
387
|
await run$3(options);
|
|
366
388
|
});
|
|
367
389
|
|
|
@@ -372,13 +394,13 @@ class Builder {
|
|
|
372
394
|
packageOptions;
|
|
373
395
|
config;
|
|
374
396
|
constructor(config) {
|
|
375
|
-
const { packageDir, packageName } = Shared.impl();
|
|
397
|
+
const { workspace, packageDir, packageName } = Shared.impl();
|
|
376
398
|
if (typeof config === 'string') {
|
|
377
399
|
let packageFolderName = config;
|
|
378
400
|
let packageDir$ = path.resolve(packageDir, packageFolderName);
|
|
379
401
|
config = {
|
|
380
402
|
dir: packageDir$,
|
|
381
|
-
name: packageFolderName,
|
|
403
|
+
name: packageFolderName || 'index',
|
|
382
404
|
input: packageDir$ + '/src/index.ts',
|
|
383
405
|
output: {
|
|
384
406
|
file: packageDir$ + '/dist/index.js',
|
|
@@ -388,8 +410,10 @@ class Builder {
|
|
|
388
410
|
}
|
|
389
411
|
};
|
|
390
412
|
}
|
|
391
|
-
this.packageDir = path.resolve(packageDir, `./${config.name}`);
|
|
392
|
-
this.packageName = config.name === 'index'
|
|
413
|
+
this.packageDir = path.resolve(packageDir, workspace ? `./${config.name}` : '');
|
|
414
|
+
this.packageName = config.name === 'index'
|
|
415
|
+
? packageName
|
|
416
|
+
: `${packageName}-${config.name}`;
|
|
393
417
|
this.packageOptions = require$$1(`${this.packageDir}/package.json`);
|
|
394
418
|
this.config = config;
|
|
395
419
|
}
|
|
@@ -410,6 +434,7 @@ class Builder {
|
|
|
410
434
|
}
|
|
411
435
|
}
|
|
412
436
|
async buildSourceAsES() {
|
|
437
|
+
const { workspace } = Shared.impl();
|
|
413
438
|
const { name, input, output } = this.config;
|
|
414
439
|
const { packageOptions } = this;
|
|
415
440
|
const external = Object
|
|
@@ -418,6 +443,9 @@ class Builder {
|
|
|
418
443
|
...packageOptions.peerDependencies
|
|
419
444
|
})
|
|
420
445
|
.map(i => new RegExp(`^${i}$`));
|
|
446
|
+
const source = workspace ? `${workspace}/${name}/**/*` : 'src/**/*';
|
|
447
|
+
const shims = workspace ? `${workspace}/shims.d.ts` : 'shims.d.ts';
|
|
448
|
+
const outDir = workspace ? `${workspace}/${name}/dist` : 'dist';
|
|
421
449
|
const builder = await rollup({
|
|
422
450
|
input,
|
|
423
451
|
external: [
|
|
@@ -427,18 +455,18 @@ class Builder {
|
|
|
427
455
|
],
|
|
428
456
|
plugins: [
|
|
429
457
|
typescript({
|
|
430
|
-
include: [
|
|
458
|
+
include: [source, shims],
|
|
431
459
|
exclude: ['dist'],
|
|
432
460
|
compilerOptions: {
|
|
433
461
|
rootDir: '.',
|
|
434
|
-
outDir
|
|
462
|
+
outDir,
|
|
435
463
|
declaration: true
|
|
436
464
|
}
|
|
437
465
|
}),
|
|
438
466
|
commonjs({ extensions: ['.js', '.ts'] }),
|
|
439
467
|
nodeResolve(),
|
|
440
468
|
replace({
|
|
441
|
-
'1.0.
|
|
469
|
+
'1.0.5': `'${packageOptions.version}'`,
|
|
442
470
|
false: 'false',
|
|
443
471
|
true: true
|
|
444
472
|
})
|
|
@@ -449,17 +477,20 @@ class Builder {
|
|
|
449
477
|
return stat;
|
|
450
478
|
}
|
|
451
479
|
async buildTypes() {
|
|
480
|
+
const { workspace } = Shared.impl();
|
|
452
481
|
const { packageDir } = this;
|
|
453
482
|
const config = path.resolve(packageDir, `api-extractor.json`);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
483
|
+
if (fs.existsSync(config)) {
|
|
484
|
+
const result = Extractor.invoke(ExtractorConfig.loadFileAndPrepare(config), {
|
|
485
|
+
localBuild: true,
|
|
486
|
+
showVerboseMessages: false
|
|
487
|
+
});
|
|
488
|
+
if (!result.succeeded) {
|
|
489
|
+
Logger.error(`API Extractor completed with ${result.errorCount} errors and ${result.warningCount} warnings`);
|
|
490
|
+
process.exitCode = 1;
|
|
491
|
+
}
|
|
461
492
|
}
|
|
462
|
-
await fs.remove(`${packageDir}/dist
|
|
493
|
+
await fs.remove(`${packageDir}/dist/${workspace || 'src'}`);
|
|
463
494
|
}
|
|
464
495
|
}
|
|
465
496
|
const builder = (options) => {
|
|
@@ -467,13 +498,14 @@ const builder = (options) => {
|
|
|
467
498
|
};
|
|
468
499
|
|
|
469
500
|
const run$1 = (options) => Utils.autoCatch(async () => {
|
|
501
|
+
const locals = Shared.impl();
|
|
470
502
|
if (typeof options.dryRun === 'undefined') {
|
|
471
503
|
options.dryRun = process.env.NODE_ENV === 'UNIT';
|
|
472
504
|
}
|
|
473
505
|
const { normalizePackageFolderNames } = Shared.impl();
|
|
474
506
|
let packageFolderName = Shared.getPackageFolderName(options.packageName || '**');
|
|
475
507
|
let inputs = [];
|
|
476
|
-
if (packageFolderName === '**') {
|
|
508
|
+
if (locals.workspace && packageFolderName === '**') {
|
|
477
509
|
inputs = normalizePackageFolderNames;
|
|
478
510
|
}
|
|
479
511
|
else {
|
|
@@ -531,7 +563,7 @@ class Releaser {
|
|
|
531
563
|
this.packageName = Shared.getPackageName(config.name);
|
|
532
564
|
this.packageFolderName = config.name;
|
|
533
565
|
this.packageOptions = require$(`${this.packageDir}/package.json`);
|
|
534
|
-
this.packageRelation = packageRelation[this.packageName];
|
|
566
|
+
this.packageRelation = packageRelation[this.packageName] || [];
|
|
535
567
|
this.config = config;
|
|
536
568
|
this.commits = [];
|
|
537
569
|
this.changeLog = '';
|
|
@@ -539,13 +571,13 @@ class Releaser {
|
|
|
539
571
|
this.commandOptions = commandOptions;
|
|
540
572
|
}
|
|
541
573
|
async parseCommits() {
|
|
574
|
+
const { workspace } = Shared.impl();
|
|
542
575
|
const { packageFolderName, packageName, commandOptions } = this;
|
|
543
576
|
let params = ['tag', '--list', `'${packageName}@*'`, '--sort', '-v:refname'];
|
|
544
577
|
const { stdout: tags } = await Shell.exec('git', params);
|
|
545
578
|
const [latestTag] = tags.split('\n');
|
|
546
579
|
Logger.log(chalk.yellow(`Last Release Tag`) + `: ${latestTag || '<none>'}`);
|
|
547
580
|
params = ['--no-pager', 'log', `${latestTag}..HEAD`, `--format=%B%n${HASH}%n%H${SUFFIX}`];
|
|
548
|
-
const rePlugin = new RegExp(`^[\\w\\!]+\\(([\\w,-]+)?${packageFolderName}([\\w,-]+)?\\)`, 'i');
|
|
549
581
|
let { stdout } = await Shell.exec('git', params);
|
|
550
582
|
let skipGetLog = false;
|
|
551
583
|
if (latestTag) {
|
|
@@ -564,11 +596,12 @@ class Releaser {
|
|
|
564
596
|
}
|
|
565
597
|
({ stdout } = await Shell.exec('git', params));
|
|
566
598
|
}
|
|
599
|
+
const rePlugin = new RegExp(`^[\\w\\!]+\\(([\\w,-]+)?${packageFolderName}([\\w,-]+)?\\)`, 'i');
|
|
567
600
|
const commits = stdout
|
|
568
601
|
.split(SUFFIX)
|
|
569
602
|
.filter((commit) => {
|
|
570
603
|
const chunk = commit.trim();
|
|
571
|
-
return chunk && rePlugin.test(chunk);
|
|
604
|
+
return chunk && (!workspace || rePlugin.test(chunk));
|
|
572
605
|
})
|
|
573
606
|
.map((commit) => {
|
|
574
607
|
const node = parser.sync(commit);
|
|
@@ -639,7 +672,7 @@ class Releaser {
|
|
|
639
672
|
this.commits = [
|
|
640
673
|
{
|
|
641
674
|
type: 'chore',
|
|
642
|
-
header: `chore(${this.packageFolderName}): force-publish ${versionChanged}`,
|
|
675
|
+
header: `chore(${this.packageFolderName || 'release'}): force-publish ${versionChanged}`,
|
|
643
676
|
hash: '',
|
|
644
677
|
effect: false,
|
|
645
678
|
breaking: false,
|
|
@@ -652,7 +685,7 @@ class Releaser {
|
|
|
652
685
|
}
|
|
653
686
|
rebuildChangeLog(commits) {
|
|
654
687
|
const { packageDir } = this;
|
|
655
|
-
const { homepage } = Shared.impl();
|
|
688
|
+
const { homepage, workspace } = Shared.impl();
|
|
656
689
|
const logPath = path.resolve(packageDir, './CHANGELOG.md');
|
|
657
690
|
const logFile = fs.existsSync(logPath) ? fs.readFileSync(logPath, 'utf-8') : '';
|
|
658
691
|
const notes = {
|
|
@@ -669,7 +702,7 @@ class Releaser {
|
|
|
669
702
|
? ''
|
|
670
703
|
: ` ([${hash?.substring(0, 7)}](${homepage}/commit/${hash}))`;
|
|
671
704
|
let message = header?.trim();
|
|
672
|
-
if (!effect) {
|
|
705
|
+
if (workspace && !effect) {
|
|
673
706
|
message = message.replace(/\(.+\)!?:/, ':');
|
|
674
707
|
}
|
|
675
708
|
message = message
|
|
@@ -898,11 +931,12 @@ class Releaser {
|
|
|
898
931
|
});
|
|
899
932
|
}
|
|
900
933
|
async process() {
|
|
934
|
+
const { workspace } = Shared.impl();
|
|
901
935
|
const { packageName, packageDir, packageFolderName } = this;
|
|
902
936
|
if (!packageDir || !fs.pathExists(packageDir)) {
|
|
903
937
|
throw new RangeError(`Could not find directory for package: ${packageFolderName}`);
|
|
904
938
|
}
|
|
905
|
-
Logger.log(chalk.cyan(`Releasing ${packageName}`) + ' from ' + chalk.grey(
|
|
939
|
+
Logger.log(chalk.cyan(`Releasing ${packageName}`) + ' from ' + chalk.grey(`${workspace}/${packageFolderName}`));
|
|
906
940
|
await this.parseCommits();
|
|
907
941
|
return this;
|
|
908
942
|
}
|
|
@@ -912,13 +946,20 @@ const releaser = (options, commandOptions) => {
|
|
|
912
946
|
};
|
|
913
947
|
|
|
914
948
|
const run = (options) => Utils.autoCatch(async () => {
|
|
949
|
+
const locals = Shared.impl();
|
|
915
950
|
if (options.dryRun) {
|
|
916
951
|
Logger.log(chalk.magenta(`DRY RUN: `)
|
|
917
952
|
+ 'No files will be modified.');
|
|
918
953
|
}
|
|
919
|
-
|
|
954
|
+
let inputs = [];
|
|
955
|
+
if (locals.workspace) {
|
|
956
|
+
inputs = locals.normalizePackageFolderNames;
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
inputs = [''];
|
|
960
|
+
}
|
|
920
961
|
const instances = {};
|
|
921
|
-
await
|
|
962
|
+
await inputs
|
|
922
963
|
.reduce((preProcess, packageFolderName) => {
|
|
923
964
|
preProcess = preProcess
|
|
924
965
|
.then(() => releaser(packageFolderName, options).process())
|
|
@@ -930,7 +971,7 @@ const run = (options) => Utils.autoCatch(async () => {
|
|
|
930
971
|
Logger.log(chalk.blue(`---------------------\n`));
|
|
931
972
|
let message = `chore(release): publish\n\n`;
|
|
932
973
|
let relationVerisons = {};
|
|
933
|
-
await
|
|
974
|
+
await inputs.reduce((preProcess, packageFolderName) => {
|
|
934
975
|
const instance = instances[packageFolderName];
|
|
935
976
|
instance.packageRelation.forEach(i => {
|
|
936
977
|
let packageFolderName$ = Shared.getPackageFolderName(i);
|
|
@@ -968,7 +1009,7 @@ const run = (options) => Utils.autoCatch(async () => {
|
|
|
968
1009
|
await Shell.spawn('git', ['add', process.cwd()]);
|
|
969
1010
|
await Shell.spawn('git', ['commit', '--m', `'${message}'`]);
|
|
970
1011
|
}
|
|
971
|
-
await
|
|
1012
|
+
await inputs
|
|
972
1013
|
.reduce((preProcess, packageFolderName) => {
|
|
973
1014
|
const instance = instances[packageFolderName];
|
|
974
1015
|
preProcess = preProcess
|
|
@@ -1024,6 +1065,7 @@ program
|
|
|
1024
1065
|
.command('dev')
|
|
1025
1066
|
.alias('d')
|
|
1026
1067
|
.description('dev')
|
|
1068
|
+
.option('-p, --package-name <string>', 'Select PackageName')
|
|
1027
1069
|
.option('--dry-run [boolean]', 'Dry Run')
|
|
1028
1070
|
.action(run$2);
|
|
1029
1071
|
program
|