Skip to content

Commit

Permalink
update 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MushStory committed Dec 27, 2022
1 parent fae3f4a commit a72d954
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 846 deletions.
6 changes: 5 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const actionRunner = async (fn = () => {}) => {
await fn();
process.exit();
} catch (e) {
if (e !== "\n" && e !== "" && e !== " ") util.consoleLogError(e);
const msg = e.message;
const output = e.output;
if (output !== false && msg !== "\n" && msg !== "" && msg !== " ") {
util.consoleLogError(msg);
}
process.exit(1);
}
};
Expand Down
9 changes: 4 additions & 5 deletions bin/cli/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ module.exports = (projectName) => {
// Install frontle core
shellUtil.shell_cp(config.path["cli/frontle_core/Frontle"], projectName);

// Install frontle git
shellUtil.shell_cp(
config.path["cli/frontle_core/FrontleGit"],
`${projectName}/.git`
);
// Init git
try {
shellUtil.shell_exec(`cd ${projectName} && git init`);
} catch (e) {}

// Success Message Output
util.consoleLogData(`Project created with name "${projectName}"`);
Expand Down
6 changes: 3 additions & 3 deletions bin/cli/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const browserify = require("browserify");
const allInstall = async () => {
try {
// Install all packages
shellUtil.shell_exec(`npm install`, false);
shellUtil.shell_exec(`npm install`);

// Check if browser_modules folder exists, create if not
if (!cliUtil.isDir(config.path["www/version/@/browser_modules"])) {
Expand Down Expand Up @@ -77,8 +77,8 @@ const install = async (enteredPackageFullName, noBuild) => {
}

// Install package
shellUtil.shell_exec(`npm uninstall ${packageFullName}`, false);
shellUtil.shell_exec(`npm install ${packageFullName}`, false);
shellUtil.shell_exec(`npm uninstall ${packageFullName}`);
shellUtil.shell_exec(`npm install ${packageFullName}`);

// Record installed package in package.json
let packageJsonData = cliUtil.getPackageJsonData();
Expand Down
1 change: 0 additions & 1 deletion bin/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ config.path = {
// cli
"cli/frontle_core": `${__dirname}/../../frontle_core`,
"cli/frontle_core/Frontle": `${__dirname}/../../frontle_core/Frontle`,
"cli/frontle_core/FrontleGit": `${__dirname}/../../frontle_core/FrontleGit`,
};

module.exports = config;
6 changes: 5 additions & 1 deletion bin/util/cli_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const checkRootPath = (checkVersionOriginal = true) => {
const getPackageJsonData = (path = `./${config.path["package.json"]}`) => {
try {
// Check if the package.json file exists
if (!fs.existsSync(path)) throw `${path} doesn\'t exist`;
if (!fs.existsSync(path)) {
throw {
message: `${path} doesn\'t exist`,
};
}

// Read package.json file
let packageJson = JSON.parse(fs.readFileSync(path).toString());
Expand Down
41 changes: 12 additions & 29 deletions bin/util/shell_util.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
const shelljs = require("shelljs");
const path = require("path");
const util = require("./util.js");
shelljs.config.silent = true;

// check shell error
const checkShellError = (result) => {
try {
if (result.stderr !== "" && String(result.code) !== "0") {
throw result.stderr;
}
} catch (e) {
throw e;
}
};

// output shell log
const outputShellLog = (result) => {
try {
if (
result.stdout !== "\n" &&
result.stdout !== "" &&
result.stdout !== " "
) {
util.consoleLogData(result.stdout);
throw {
message: result.stderr,
output: false,
};
}
} catch (e) {
throw e;
}
};

// shell: exec
const shell_exec = (command, silent = true) => {
const shell_exec = (command) => {
try {
const result = shelljs.exec(command, {
silent: silent,
});
if (!silent) return;
const result = shelljs.exec(command);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand All @@ -48,7 +31,7 @@ const shell_rm = (path, option = "-rf") => {
try {
const result = shelljs.rm(option, path);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand All @@ -62,7 +45,7 @@ const shell_cp = (fromPath, toPath, option = "-Rf") => {

const result = shelljs.cp(option, fromPath, toPath);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand All @@ -76,7 +59,7 @@ const shell_mv = (fromPath, toPath, option = "-f") => {

const result = shelljs.mv(option, fromPath, toPath);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand All @@ -87,7 +70,7 @@ const shell_mkdir = (path, option = "-p") => {
try {
const result = shelljs.mkdir(option, path);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand All @@ -98,7 +81,7 @@ const shell_echo = (message) => {
try {
const result = shelljs.echo(message);
checkShellError(result);
outputShellLog(result);
return result;
} catch (e) {
throw e;
}
Expand Down
1 change: 0 additions & 1 deletion frontle_core/FrontleGit/HEAD

This file was deleted.

6 changes: 0 additions & 6 deletions frontle_core/FrontleGit/config

This file was deleted.

1 change: 0 additions & 1 deletion frontle_core/FrontleGit/description

This file was deleted.

15 changes: 0 additions & 15 deletions frontle_core/FrontleGit/hooks/applypatch-msg.sample

This file was deleted.

24 changes: 0 additions & 24 deletions frontle_core/FrontleGit/hooks/commit-msg.sample

This file was deleted.

174 changes: 0 additions & 174 deletions frontle_core/FrontleGit/hooks/fsmonitor-watchman.sample

This file was deleted.

Loading

0 comments on commit a72d954

Please sign in to comment.