binhend 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/create-frontend.js +4 -4
- package/bin/commands/start-frontend.js +11 -0
- package/bin/index.js +4 -1
- package/bin/utils/cmdRun.js +27 -0
- package/package.json +1 -1
- package/test/package.json +0 -19
|
@@ -5,14 +5,14 @@ const fs = require('fs');
|
|
|
5
5
|
module.exports = (args) => {
|
|
6
6
|
try {
|
|
7
7
|
var currentDirectory = process.cwd(), // directory path where the command is executed
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
destinationPath = path.join(currentDirectory, args[0] || 'frontend'),
|
|
9
|
+
sourcePath = path.join(__dirname, '../templates/frontend');
|
|
10
10
|
|
|
11
|
-
console.log('[BINHEND][
|
|
11
|
+
console.log('[BINHEND][CLI] Generate front-end structure:', destinationPath);
|
|
12
12
|
fs.cpSync(sourcePath, destinationPath, {recursive: true});
|
|
13
13
|
}
|
|
14
14
|
catch (error) {
|
|
15
|
-
console.error('[BINHEND][
|
|
15
|
+
console.error('[BINHEND][CLI] Error generating front-end structure!');
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const runCommand = require('../utils/cmdRun');
|
|
5
|
+
|
|
6
|
+
module.exports = (args) => {
|
|
7
|
+
var currentDirectory = process.cwd(), // directory path where the command is executed
|
|
8
|
+
destinationPath = path.join(currentDirectory, args[0] || 'frontend', 'server.js');
|
|
9
|
+
|
|
10
|
+
runCommand('node', [destinationPath]);
|
|
11
|
+
};
|
package/bin/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const commandMap = {
|
|
4
4
|
create: {
|
|
5
5
|
backend: () => require('./commands/create-backend'),
|
|
6
6
|
frontend: () => require('./commands/create-frontend'),
|
|
7
|
+
},
|
|
8
|
+
start: {
|
|
9
|
+
frontend: () => require('./commands/start-frontend'),
|
|
7
10
|
}
|
|
8
11
|
};
|
|
9
12
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
|
|
4
|
+
function print(data) {
|
|
5
|
+
process.stdout.write(`${data}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function printErr(fullCommand, error) {
|
|
9
|
+
process.stdout.write(`[BINHEND][CLI] Error executing command: ${fullCommand}\n`);
|
|
10
|
+
process.stdout.write(`${error}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = function() {
|
|
14
|
+
const command = arguments[0],
|
|
15
|
+
args = arguments[1],
|
|
16
|
+
fullCommand = `${command} ${args.join(' ')}`,
|
|
17
|
+
|
|
18
|
+
printError = printErr.bind(null, fullCommand),
|
|
19
|
+
|
|
20
|
+
child = spawn.apply(null, arguments);
|
|
21
|
+
|
|
22
|
+
child.stdout.on('data', print);
|
|
23
|
+
|
|
24
|
+
child.stderr.on('data', printError);
|
|
25
|
+
|
|
26
|
+
child.on('error', printError);
|
|
27
|
+
};
|
package/package.json
CHANGED
package/test/package.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "palindrome",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"directories": {
|
|
7
|
-
"test": "test"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "istanbul cover node_modules/mocha/bin/_mocha"
|
|
11
|
-
},
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"chai": "^3.5.0",
|
|
16
|
-
"istanbul": "^0.4.4",
|
|
17
|
-
"mocha": "^3.0.1"
|
|
18
|
-
}
|
|
19
|
-
}
|