Skip to content

Commit

Permalink
fix: replace taskfile module
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 14, 2020
1 parent ddc3786 commit e828baa
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 59 deletions.
41 changes: 20 additions & 21 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,26 @@

[CHANGELOG](CHANGELOG.md)

- [Introduction](#Introduction)
- [GitHub](#Github)
- [Preview](#Preview)
- [Documentation](#Documentation)
- [Preinstallation](#Preinstallation)
- [Environmental requirements](#Environmental requirements)
- [UI framework](#ui framework)
- [Icon](#Icon)
- [Plugin](#Plugin)
- [Suggested development environment](#Suggested development environment)
- [Install](#Install)
- [Usage](#Usage)
- [Development environment](#Development environment)
- [Build](#Build)
- [Format](#Format)
- [Other](#Other)
- [Git submit specifications](#git submit specifications)
- [Code ontribution](#Code ontribution)
- [Finished features](#Finished features)
- [Developing features](#Developing features)
- [Join us](#Join us)
- [Introduction](#introduction)
- [GitHub](#github)
- [Preview](#preview)
- [Documentation](#documentation)
- [Preinstallation](#preinstallation)
- [Environmental requirements](#environmental-requirements)
- [UI framework](#ui-framework)
- [Icon](#icon)
- [Plugin](#plugin)
- [Suggested development environment](#suggested-development-environment)
- [Install](#install)
- [Usage](#usage)
- [Development environment](#development-environment)
- [Build](#build)
- [Format](#format)
- [Other](#other)
- [Git submit specifications](#git-submit-specifications)
- [Code contribution](#code-contribution)
- [Finished features](#finished-features)
- [Developing features](#developing-features)

## Introduction

Expand Down
30 changes: 23 additions & 7 deletions build/jsc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// js调用cli 兼容调用ts

const { sh } = require('tasksfile');
// const { sh } = require('tasksfile');
const { argv } = require('yargs');
const execa = require('execa');

let command = ``;

Expand All @@ -24,13 +25,28 @@ if (taskList.includes('build') || taskList.includes('report') || taskList.includ
}

if (taskList && Array.isArray(taskList) && taskList.length) {
sh(
`cross-env NODE_ENV=${NODE_ENV} ts-node --project ./build/tsconfig.json ./build/script/cli.ts ${taskList.join(
' '
)} ${command}`,
execa(
'cross-env',
[
`NODE_ENV=${NODE_ENV}`,
'ts-node',
'--project',
'./build/tsconfig.json',
'./build/script/cli.ts',
taskList.join(' '),
command,
],
{
async: true,
nopipe: true,
stdio: 'inherit',
}
);
// sh(
// `cross-env NODE_ENV=${NODE_ENV} ts-node --project ./build/tsconfig.json ./build/script/cli.ts ${taskList.join(
// ' '
// )} ${command}`,
// {
// async: true,
// nopipe: true,
// }
// );
}
15 changes: 8 additions & 7 deletions build/script/build.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// #!/usr/bin/env node

import { sh } from 'tasksfile';
// import { sh } from 'tasksfile';

import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
import { runUpdateHtml } from './updateHtml';
import { errorConsole, successConsole } from '../utils';
import { errorConsole, successConsole, run } from '../utils';

export const runBuild = async () => {
try {
const argvList = argv._;
let cmd = `npx cross-env NODE_ENV=production vite build`;
await sh(cmd, {
async: true,
nopipe: true,
});
// let cmd = `cross-env NODE_ENV=production vite build`;
await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
// await sh(cmd, {
// async: true,
// nopipe: true,
// });

// Generate configuration file
if (!argvList.includes('no-conf')) {
Expand Down
33 changes: 21 additions & 12 deletions build/script/changelog.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
// #!/usr/bin/env node

import { sh } from 'tasksfile';
import { errorConsole, successConsole } from '../utils';
// import { sh } from 'tasksfile';
import { errorConsole, successConsole, run } from '../utils';

export const runChangeLog = async () => {
try {
let cmd = `conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 `;
await sh(cmd, {
async: true,
nopipe: true,
});

await sh('prettier --write **/CHANGELOG.md ', {
async: true,
nopipe: true,
});
// let cmd = `conventional-changelog -p custom-config -i CHANGELOG.md -s -r 0 `;
await run('conventional-changelog', [
'-p',
'custom-config',
'-i',
'CHANGELOG.md',
'-s',
'-r',
'-0',
]);
// await sh(cmd, {
// async: true,
// nopipe: true,
// });
await run('prettier', ['--write', '**/CHANGELOG.md']);
// await sh('prettier --write **/CHANGELOG.md ', {
// async: true,
// nopipe: true,
// });
successConsole('CHANGE_LOG.md generated successfully!');
} catch (error) {
errorConsole('CHANGE_LOG.md generated error\n' + error);
Expand Down
13 changes: 7 additions & 6 deletions build/script/preserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import path from 'path';
import fs from 'fs-extra';
import { isEqual } from 'lodash';
import { sh } from 'tasksfile';
import { successConsole, errorConsole } from '../utils';
// import { sh } from 'tasksfile';
import { successConsole, errorConsole, run } from '../utils';

const resolve = (dir: string) => {
return path.resolve(process.cwd(), dir);
Expand Down Expand Up @@ -46,10 +46,11 @@ export async function runPreserve() {
'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)!'
);
try {
await sh('npm run bootstrap ', {
async: true,
nopipe: true,
});
await run('npm', ['run', 'bootstrap']);
// await sh('npm run bootstrap ', {
// async: true,
// nopipe: true,
// });

successConsole('Dependency installation is successful, start running the project!');

Expand Down
13 changes: 7 additions & 6 deletions build/script/preview.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import chalk from 'chalk';
import Koa from 'koa';
import inquirer from 'inquirer';
import { sh } from 'tasksfile';
// import { sh } from 'tasksfile';
import staticServer from 'koa-static';
import portfinder from 'portfinder';
import { resolve } from 'path';
import viteConfig from '../../vite.config';
import { getIPAddress } from '../utils';
import { getIPAddress, run } from '../utils';

const BUILD = 1;
const NO_BUILD = 2;
Expand Down Expand Up @@ -53,10 +53,11 @@ export const runPreview = async () => {
});
const { type } = await prompt;
if (type === BUILD) {
await sh('npm run build', {
async: true,
nopipe: true,
});
await run('npm', ['run', 'build']);
// await sh('npm run build', {
// async: true,
// nopipe: true,
// });
}
startApp();
};
4 changes: 4 additions & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import { networkInterfaces } from 'os';
import dotenv from 'dotenv';
import chalk from 'chalk';
import execa from 'execa';

export const isFunction = (arg: unknown): arg is (...args: any[]) => any =>
typeof arg === 'function';
Expand Down Expand Up @@ -147,3 +148,6 @@ export function warnConsole(message: any) {
export function getCwdPath(...dir: string[]) {
return path.resolve(process.cwd(), ...dir);
}

export const run = (bin: string, args: any, opts = {}) =>
execa(bin, args, { stdio: 'inherit', ...opts });

0 comments on commit e828baa

Please sign in to comment.