Skip to content

Commit 9a8175c

Browse files
committed
Base code for ara cli
0 parents  commit 9a8175c

9 files changed

Lines changed: 149 additions & 0 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*]
2+
indent_size = 2
3+
indent_style = space

.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"airbnb-base"
4+
]
5+
}

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Directory for instrumented libs generated by jscoverage/JSCover
7+
lib-cov
8+
9+
# Coverage directory used by tools like istanbul
10+
coverage
11+
12+
# node-waf configuration
13+
.lock-wscript
14+
15+
# Compiled binary addons (http://nodejs.org/api/addons.html)
16+
build/Release
17+
18+
# Dependency directory
19+
node_modules
20+
21+
# Optional npm cache directory
22+
.npm
23+
24+
# Optional REPL history
25+
.node_repl_history
26+
27+
TODO
28+
coverage
29+
lib
30+
31+
# Only apps should have lockfiles
32+
npm-shrinkwrap.json
33+
yarn.lock
34+
package-lock.json
35+
© 2019 GitHub, Inc.
36+
Terms
37+
Privacy
38+
Security
39+
Status
40+
Help
41+
Contact GitHub
42+
Pricing
43+
API
44+
Training
45+
Blog
46+
About

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "ara-cli",
3+
"version": "0.1.0",
4+
"description": "Ara Framework Command Line Interface",
5+
"main": "src/index.js",
6+
"bin": {
7+
"ara": "src/index.js"
8+
},
9+
"license": "MIT",
10+
"scripts": {
11+
"prepublish": "npm run lint",
12+
"lint": "eslint ."
13+
},
14+
"dependencies": {
15+
"cac": "^6.5.2",
16+
"chalk": "^2.4.2",
17+
"majo": "^0.7.1",
18+
"sao": "^1.6.1"
19+
},
20+
"devDependencies": {
21+
"eslint": "^5.16.0",
22+
"eslint-config-airbnb-base": "^13.1.0",
23+
"eslint-plugin-import": "^2.17.3"
24+
}
25+
}

src/generators/project/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const majo = require('majo');
4+
const chalk = require('chalk');
5+
6+
module.exports = (name) => {
7+
const appPath = path.join(process.cwd(), name);
8+
9+
if (fs.existsSync(appPath)) {
10+
throw new Error(`Cannot override contents of [${name}]. Make sure to delete it or specify a new path`);
11+
}
12+
13+
fs.mkdirSync(appPath);
14+
15+
const stream = majo();
16+
17+
const templatePath = path.join(__dirname, 'template');
18+
19+
return stream.source('**', {
20+
baseDir: templatePath,
21+
})
22+
.dest(appPath)
23+
.then(() => console.log(chalk.green(`Project [${name}] Created!!`))); /* eslint-disable-line no-console */
24+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ara
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.1'
2+
3+
services:
4+
5+
nova-cluster:
6+
restart: always
7+
build: ./.ara/cluster
8+
ports:
9+
- 3000:8000
10+
11+
nova-proxy:
12+
restart: always
13+
build: ./.ara/proxy
14+
ports:
15+
- 8080:8080
16+
links:
17+
- nova-cluster
18+
environment:
19+
HYPERNOVA_BATCH: http://nova-cluster:8000/batch
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nova Micro-frontends here

src/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
const cli = require('cac')();
3+
4+
const path = require('path');
5+
const sao = require('sao');
6+
7+
const generateProject = require('./generators/project');
8+
9+
cli.command('new:project <outDir>', 'New Project')
10+
.action(outDir => generateProject(outDir));
11+
12+
cli.command('new:nova <outDir>', 'New Micro-Frontend')
13+
.option('-t, --template <template>', 'Template Type')
14+
.action((outDir, { template = 'vue' }) => {
15+
const appPath = path.join(process.cwd(), outDir);
16+
const options = {
17+
outDir: appPath,
18+
generator: `ara-framework/create-hypernova-${template}`,
19+
};
20+
21+
return sao(options)
22+
.run();
23+
});
24+
25+
cli.parse();

0 commit comments

Comments
 (0)