Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 577578b

Browse files
authored
Merge pull request #10 from fastjs-team/dev
Version 2.4.5
2 parents 7e21a9c + 4afe071 commit 577578b

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

lib/build.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const output = require('./console/output');
22
const outputDev = require('./console/outputDev');
3-
const load = require("ora");
3+
const loader = require('./console/loader');
44
const fs = require("fs-extra");
55
const path = require("path");
66
const pc = require("picocolors");
@@ -15,8 +15,7 @@ async function build(options) {
1515
const startTime = Date.now();
1616
// close spin if dev
1717
await outputDev("Spinners are disabled in dev mode");
18-
const spinner = fs.pathExistsSync(path.join(process.cwd(), "ondev.key")) ? {} :
19-
load("Building project...").start();
18+
const load = new loader("Building project", "Checking project", 6);
2019
await outputDev("Building project...");
2120
await outputDev(`spawn in ${process.cwd()}`);
2221
await outputDev("")
@@ -35,45 +34,49 @@ async function build(options) {
3534
return
3635
}
3736

37+
load.update("Checking output dir", 1);
38+
3839
// setup input dir
3940
// if not exists
4041
if (!fs.existsSync(path.join(process.cwd(), outputDir))) {
4142
// create output dir
4243
await outputDev(`Creating dir ${path.join(process.cwd(), outputDir)}`);
43-
spinner.text = "Creating output dir...";
44+
load.update("Creating output dir", 2);
4445
fs.mkdirSync(path.join(process.cwd(), outputDir));
4546
} else {
4647
// clear output dir
4748
await outputDev(`Clearing dir ${path.join(process.cwd(), outputDir)}`);
48-
spinner.text = "Clearing output dir...";
49+
load.update("Clearing output dir", 2);
4950
fs.emptyDirSync(path.join(process.cwd(), outputDir));
5051
}
5152

5253
// run vite build
5354
await outputDev("Running vite build...");
54-
spinner.text = "Building project...";
55+
load.update("Building project", 3);
5556
const {exec} = require("child_process");
5657
exec(`vite build`, {cwd: process.cwd()}, (err) => {
5758
if (err) {
58-
spinner.stop();
59+
load.end();
5960
outputDev("Error: vite build error");
6061
outputDev("Program exit by error");
6162
output("There was an error building the project, open dev mode to see more info", "red");
6263
return
6364
}
6465
// find fastjs_build_temp
6566
if (!fs.existsSync(path.join(process.cwd(), "fastjs_build_temp"))) {
66-
spinner.stop();
67+
load.end();
6768
outputDev("Error: fastjs_build_temp not found");
6869
outputDev("Program exit by error");
6970
output("There was an error building the project, open dev mode to see more info", "red");
7071
return
7172
}
7273
// move to output dir
7374
outputDev("Moving files to output dir...");
75+
load.update("Moving files to output dir", 4);
7476
fs.copySync(path.join(process.cwd(), "fastjs_build_temp"), path.join(process.cwd(), outputDir));
7577
// remove fastjs_build_temp
7678
outputDev("Removing fastjs_build_temp...");
79+
load.update("Removing temp", 5);
7780
fs.removeSync(path.join(process.cwd(), "fastjs_build_temp"));
7881
// check fastjs_build_temp
7982
const printList = []
@@ -111,7 +114,7 @@ async function build(options) {
111114
}
112115
readDir("\\")
113116
// show success
114-
spinner.stop();
117+
load.end();
115118
output(`${pc.bold("[Fastjs-cli]")}`, "green");
116119
output("")
117120
output(`*green*${pc.bold("Fastjs-cli")} v${Version}*green* build success in ${Date.now() - startTime}ms`);

lib/dev.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const output = require('./console/output');
22
const outputDev = require('./console/outputDev');
3-
const load = require("ora");
3+
const loader = require('./console/loader');
44
const fs = require("fs-extra");
55
const path = require("path");
66
const pc = require("picocolors");
@@ -14,8 +14,7 @@ async function dev(options) {
1414
const startTime = Date.now();
1515
// close spin if dev
1616
await outputDev("Spinners are disabled in dev mode");
17-
const spinner = fs.pathExistsSync(path.join(process.cwd(), "ondev.key")) ? {} :
18-
load("Starting dev server...").start();
17+
const load = new loader("Starting dev server", "Checking port", 2);
1918
await outputDev("Starting dev server...");
2019
await outputDev(`spawn in ${process.cwd()}`);
2120
await outputDev("")
@@ -27,13 +26,13 @@ async function dev(options) {
2726
if (options.port) {
2827
// check is number
2928
if (isNaN(options.port) || options.port.length !== 4) {
30-
spinner.stop();
29+
load.end();
3130
await outputDev("Error: port is not a number");
3231
await outputDev("Program exit by error");
3332
await output("Error: port should be a 4 sig number", "red");
3433
return
3534
} else if (await checkPort(port)) {
36-
spinner.stop();
35+
load.end();
3736
await outputDev("Error: port is busy");
3837
await outputDev("Program exit by error");
3938
await output("Error: port is busy", "red");
@@ -46,7 +45,7 @@ async function dev(options) {
4645
stopPort: 4000
4746
}, (err, active) => {
4847
if (err) {
49-
spinner.stop();
48+
load.end();
5049
outputDev("Error: port 3000-4000 all busy");
5150
outputDev("Program exit by error");
5251
output("Error: port 3000-4000 all busy", "red");
@@ -57,21 +56,22 @@ async function dev(options) {
5756
}
5857
// run command `vite` and listen for stdout
5958
const {exec} = require("child_process");
59+
load.update("Starting server", 1);
6060
const vite = exec(`vite --port ${port}`, {cwd: process.cwd()}, error => {
6161
if (error) {
62-
spinner.stop();
62+
load.end();
6363
outputDev(error);
6464
outputDev("Program exit by error");
6565
output(String(error))
6666
return;
6767
}
68-
spinner.stop();
68+
load.end();
6969
outputDev("Program exit by vite");
7070
});
7171
vite.stdout.on("data", data => {
7272
// if include `ready in` then vite is ready
7373
if (data.toString().includes("ready in")) {
74-
spinner.stop();
74+
load.end();
7575
output(`${pc.bold("[Fastjs-cli]")}`, "green");
7676
output("")
7777
const Version = require("../package.json").version;

modules/vue-router/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<router-view v-slot="{ Component }">
3-
<transition name="fade" mode="out-in">
3+
<transition name="fade">
44
<component :is="Component" />
55
</transition>
66
</router-view>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fastjs-cli",
3-
"version": "2.4.4",
3+
"version": "2.4.5",
44
"description": "Fastjs-cli can help you build a npm project easily.",
55
"main": "index.js",
66
"bin": {

0 commit comments

Comments
 (0)