-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.ts
84 lines (78 loc) · 1.89 KB
/
runner.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Listr, delay } from 'listr2';
import type { ResolvedOptions } from '../types/options.js';
import { packageName } from '../utils/package-json.js';
import { jsrPubmTasks } from './jsr.js';
import { npmPubmTasks } from './npm.js';
import { prerequisitesCheckTask } from './prerequisites-check.js';
import { requiredConditionsCheckTask } from './required-conditions-check.js';
export interface Ctx extends ResolvedOptions {
progressingPrompt?: Promise<void>;
}
export async function run(options: ResolvedOptions) {
const ctx = { ...options };
try {
await prerequisitesCheckTask({ skip: options.skipPrerequisitesCheck }).run(
ctx,
);
await requiredConditionsCheckTask({
skip: options.skipConditionsCheck,
}).run(ctx);
await new Listr([
{
skip: options.skipTests,
title: 'Running tests',
task: async (_, task) => {
task.output = 'All good';
await delay(1000);
},
},
{
skip: options.skipBuild,
title: 'Building the project',
task: async (_, task) => {
task.output = 'All good';
await delay(1000);
},
},
{
title: 'Bumping version',
task: async (_, task) => {
task.output = 'All good';
await delay(1000);
},
},
{
skip: options.skipPublish,
title: 'Publishing',
task: (_, parentTask) =>
parentTask.newListr([npmPubmTasks, jsrPubmTasks], {
exitOnError: true,
concurrent: true,
ctx,
}),
},
{
title: 'Pushing tags to GitHub',
task: async (_, task) => {
task.output = 'All good';
await delay(1000);
},
},
{
skip: options.skipReleaseDraft,
title: 'Creating release draft on GitHub',
task: async (_, task) => {
task.output = 'All good';
await delay(1000);
},
},
]).run(ctx);
console.log(
`
🚀 Successfully published ${await packageName()} v${ctx.version} 🚀
`,
);
} catch (e) {
console.error(e);
}
}