Commit e828baa67b5f8e6fa28354d85563d127b6b70d6b

Authored by vben
1 parent ddc3786b

fix: replace taskfile module

README.en-US.md
@@ -9,27 +9,26 @@ @@ -9,27 +9,26 @@
9 9
10 [CHANGELOG](CHANGELOG.md) 10 [CHANGELOG](CHANGELOG.md)
11 11
12 -- [Introduction](#Introduction)  
13 -- [GitHub](#Github)  
14 -- [Preview](#Preview)  
15 -- [Documentation](#Documentation)  
16 -- [Preinstallation](#Preinstallation)  
17 - - [Environmental requirements](#Environmental requirements)  
18 - - [UI framework](#ui framework)  
19 - - [Icon](#Icon)  
20 - - [Plugin](#Plugin)  
21 - - [Suggested development environment](#Suggested development environment)  
22 -- [Install](#Install)  
23 -- [Usage](#Usage)  
24 - - [Development environment](#Development environment)  
25 - - [Build](#Build)  
26 - - [Format](#Format)  
27 - - [Other](#Other)  
28 -- [Git submit specifications](#git submit specifications)  
29 -- [Code ontribution](#Code ontribution)  
30 -- [Finished features](#Finished features)  
31 -- [Developing features](#Developing features)  
32 -- [Join us](#Join us) 12 +- [Introduction](#introduction)
  13 +- [GitHub](#github)
  14 +- [Preview](#preview)
  15 +- [Documentation](#documentation)
  16 +- [Preinstallation](#preinstallation)
  17 + - [Environmental requirements](#environmental-requirements)
  18 + - [UI framework](#ui-framework)
  19 + - [Icon](#icon)
  20 + - [Plugin](#plugin)
  21 + - [Suggested development environment](#suggested-development-environment)
  22 +- [Install](#install)
  23 +- [Usage](#usage)
  24 + - [Development environment](#development-environment)
  25 + - [Build](#build)
  26 + - [Format](#format)
  27 + - [Other](#other)
  28 +- [Git submit specifications](#git-submit-specifications)
  29 +- [Code contribution](#code-contribution)
  30 +- [Finished features](#finished-features)
  31 +- [Developing features](#developing-features)
33 32
34 ## Introduction 33 ## Introduction
35 34
build/jsc.js
1 // js调用cli 兼容调用ts 1 // js调用cli 兼容调用ts
2 2
3 -const { sh } = require('tasksfile'); 3 +// const { sh } = require('tasksfile');
4 const { argv } = require('yargs'); 4 const { argv } = require('yargs');
  5 +const execa = require('execa');
5 6
6 let command = ``; 7 let command = ``;
7 8
@@ -24,13 +25,28 @@ if (taskList.includes('build') || taskList.includes('report') || taskList.includ @@ -24,13 +25,28 @@ if (taskList.includes('build') || taskList.includes('report') || taskList.includ
24 } 25 }
25 26
26 if (taskList && Array.isArray(taskList) && taskList.length) { 27 if (taskList && Array.isArray(taskList) && taskList.length) {
27 - sh(  
28 - `cross-env NODE_ENV=${NODE_ENV} ts-node --project ./build/tsconfig.json ./build/script/cli.ts ${taskList.join(  
29 - ' '  
30 - )} ${command}`, 28 + execa(
  29 + 'cross-env',
  30 + [
  31 + `NODE_ENV=${NODE_ENV}`,
  32 + 'ts-node',
  33 + '--project',
  34 + './build/tsconfig.json',
  35 + './build/script/cli.ts',
  36 + taskList.join(' '),
  37 + command,
  38 + ],
31 { 39 {
32 - async: true,  
33 - nopipe: true, 40 + stdio: 'inherit',
34 } 41 }
35 ); 42 );
  43 + // sh(
  44 + // `cross-env NODE_ENV=${NODE_ENV} ts-node --project ./build/tsconfig.json ./build/script/cli.ts ${taskList.join(
  45 + // ' '
  46 + // )} ${command}`,
  47 + // {
  48 + // async: true,
  49 + // nopipe: true,
  50 + // }
  51 + // );
36 } 52 }
build/script/build.ts
1 // #!/usr/bin/env node 1 // #!/usr/bin/env node
2 2
3 -import { sh } from 'tasksfile'; 3 +// import { sh } from 'tasksfile';
4 4
5 import { argv } from 'yargs'; 5 import { argv } from 'yargs';
6 import { runBuildConfig } from './buildConf'; 6 import { runBuildConfig } from './buildConf';
7 import { runUpdateHtml } from './updateHtml'; 7 import { runUpdateHtml } from './updateHtml';
8 -import { errorConsole, successConsole } from '../utils'; 8 +import { errorConsole, successConsole, run } from '../utils';
9 9
10 export const runBuild = async () => { 10 export const runBuild = async () => {
11 try { 11 try {
12 const argvList = argv._; 12 const argvList = argv._;
13 - let cmd = `npx cross-env NODE_ENV=production vite build`;  
14 - await sh(cmd, {  
15 - async: true,  
16 - nopipe: true,  
17 - }); 13 + // let cmd = `cross-env NODE_ENV=production vite build`;
  14 + await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
  15 + // await sh(cmd, {
  16 + // async: true,
  17 + // nopipe: true,
  18 + // });
18 19
19 // Generate configuration file 20 // Generate configuration file
20 if (!argvList.includes('no-conf')) { 21 if (!argvList.includes('no-conf')) {
build/script/changelog.ts
1 // #!/usr/bin/env node 1 // #!/usr/bin/env node
2 2
3 -import { sh } from 'tasksfile';  
4 -import { errorConsole, successConsole } from '../utils'; 3 +// import { sh } from 'tasksfile';
  4 +import { errorConsole, successConsole, run } from '../utils';
5 5
6 export const runChangeLog = async () => { 6 export const runChangeLog = async () => {
7 try { 7 try {
8 - let cmd = `conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 `;  
9 - await sh(cmd, {  
10 - async: true,  
11 - nopipe: true,  
12 - });  
13 -  
14 - await sh('prettier --write **/CHANGELOG.md ', {  
15 - async: true,  
16 - nopipe: true,  
17 - }); 8 + // let cmd = `conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 `;
  9 + await run('conventional-changelog', [
  10 + '-p',
  11 + 'custom-config',
  12 + '-i',
  13 + 'CHANGELOG.md',
  14 + '-s',
  15 + '-r',
  16 + '-0',
  17 + ]);
  18 + // await sh(cmd, {
  19 + // async: true,
  20 + // nopipe: true,
  21 + // });
  22 + await run('prettier', ['--write', '**/CHANGELOG.md']);
  23 + // await sh('prettier --write **/CHANGELOG.md ', {
  24 + // async: true,
  25 + // nopipe: true,
  26 + // });
18 successConsole('CHANGE_LOG.md generated successfully!'); 27 successConsole('CHANGE_LOG.md generated successfully!');
19 } catch (error) { 28 } catch (error) {
20 errorConsole('CHANGE_LOG.md generated error\n' + error); 29 errorConsole('CHANGE_LOG.md generated error\n' + error);
build/script/preserve.ts
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 import path from 'path'; 3 import path from 'path';
4 import fs from 'fs-extra'; 4 import fs from 'fs-extra';
5 import { isEqual } from 'lodash'; 5 import { isEqual } from 'lodash';
6 -import { sh } from 'tasksfile';  
7 -import { successConsole, errorConsole } from '../utils'; 6 +// import { sh } from 'tasksfile';
  7 +import { successConsole, errorConsole, run } from '../utils';
8 8
9 const resolve = (dir: string) => { 9 const resolve = (dir: string) => {
10 return path.resolve(process.cwd(), dir); 10 return path.resolve(process.cwd(), dir);
@@ -46,10 +46,11 @@ export async function runPreserve() { @@ -46,10 +46,11 @@ export async function runPreserve() {
46 'A dependency change is detected, and the dependency is being installed to ensure that the dependency is consistent! (Tip: The project will be executed for the first time)!' 46 'A dependency change is detected, and the dependency is being installed to ensure that the dependency is consistent! (Tip: The project will be executed for the first time)!'
47 ); 47 );
48 try { 48 try {
49 - await sh('npm run bootstrap ', {  
50 - async: true,  
51 - nopipe: true,  
52 - }); 49 + await run('npm', ['run', 'bootstrap']);
  50 + // await sh('npm run bootstrap ', {
  51 + // async: true,
  52 + // nopipe: true,
  53 + // });
53 54
54 successConsole('Dependency installation is successful, start running the project!'); 55 successConsole('Dependency installation is successful, start running the project!');
55 56
build/script/preview.ts
1 import chalk from 'chalk'; 1 import chalk from 'chalk';
2 import Koa from 'koa'; 2 import Koa from 'koa';
3 import inquirer from 'inquirer'; 3 import inquirer from 'inquirer';
4 -import { sh } from 'tasksfile'; 4 +// import { sh } from 'tasksfile';
5 import staticServer from 'koa-static'; 5 import staticServer from 'koa-static';
6 import portfinder from 'portfinder'; 6 import portfinder from 'portfinder';
7 import { resolve } from 'path'; 7 import { resolve } from 'path';
8 import viteConfig from '../../vite.config'; 8 import viteConfig from '../../vite.config';
9 -import { getIPAddress } from '../utils'; 9 +import { getIPAddress, run } from '../utils';
10 10
11 const BUILD = 1; 11 const BUILD = 1;
12 const NO_BUILD = 2; 12 const NO_BUILD = 2;
@@ -53,10 +53,11 @@ export const runPreview = async () => { @@ -53,10 +53,11 @@ export const runPreview = async () => {
53 }); 53 });
54 const { type } = await prompt; 54 const { type } = await prompt;
55 if (type === BUILD) { 55 if (type === BUILD) {
56 - await sh('npm run build', {  
57 - async: true,  
58 - nopipe: true,  
59 - }); 56 + await run('npm', ['run', 'build']);
  57 + // await sh('npm run build', {
  58 + // async: true,
  59 + // nopipe: true,
  60 + // });
60 } 61 }
61 startApp(); 62 startApp();
62 }; 63 };
build/utils.ts
@@ -3,6 +3,7 @@ import path from 'path'; @@ -3,6 +3,7 @@ import path from 'path';
3 import { networkInterfaces } from 'os'; 3 import { networkInterfaces } from 'os';
4 import dotenv from 'dotenv'; 4 import dotenv from 'dotenv';
5 import chalk from 'chalk'; 5 import chalk from 'chalk';
  6 +import execa from 'execa';
6 7
7 export const isFunction = (arg: unknown): arg is (...args: any[]) => any => 8 export const isFunction = (arg: unknown): arg is (...args: any[]) => any =>
8 typeof arg === 'function'; 9 typeof arg === 'function';
@@ -147,3 +148,6 @@ export function warnConsole(message: any) { @@ -147,3 +148,6 @@ export function warnConsole(message: any) {
147 export function getCwdPath(...dir: string[]) { 148 export function getCwdPath(...dir: string[]) {
148 return path.resolve(process.cwd(), ...dir); 149 return path.resolve(process.cwd(), ...dir);
149 } 150 }
  151 +
  152 +export const run = (bin: string, args: any, opts = {}) =>
  153 + execa(bin, args, { stdio: 'inherit', ...opts });