Skip to content

Commit b83b7a6

Browse files
committed
Update code to ESM, rewrite readme
1 parent 24b538c commit b83b7a6

File tree

16 files changed

+93
-112
lines changed

16 files changed

+93
-112
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
npm-debug.log
33
yarn.lock
4+
package-lock.json
45
.DS_Store

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "none",
4-
"printWidth": 100
4+
"arrowParens": "avoid",
5+
"printWidth": 90
56
}

package-lock.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
22
"name": "create-nativeweb",
33
"version": "0.1.1",
4-
"description": "🎨 Command-line tool for Native Web.",
4+
"description": "🧶 Command-line tool for Native Web.",
55
"repository": "nativew/create",
66
"author": "Antoine Boulanger (https://github.com/antoineboulanger)",
77
"license": "ISC",
8+
"exports": "./src/index.js",
89
"main": "src/index.js",
10+
"type": "module",
911
"bin": {
1012
"nativeweb": "src/index.js"
1113
},
1214
"scripts": {
13-
"format": "prettier --write 'src/**/*.js'"
14-
},
15-
"devDependencies": {
16-
"prettier": "^2.0.5"
15+
"format": "prettier --write --ignore-unknown '**/*'"
1716
},
1817
"files": [
1918
"src"
20-
]
19+
],
20+
"devDependencies": {
21+
"prettier": "^2.2.1"
22+
}
2123
}

readme.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
# Create 🎨
1+
# Create 🧶
2+
23
Command-line tool for [Native Web](https://github.com/nativew/nativeweb).
34

4-
## ✨ Features
5-
- **Init**. Start a project with [Start](https://github.com/nativew/start) 🧨.
5+
<br>
6+
7+
### Initialize your project
8+
9+
### Right from the terminal
10+
11+
<br>
12+
13+
### One command to [start](https://github.com/nativew/start)
614

7-
## 🚀 Start
815
```zsh
9-
# Create a new project
1016
npm init nativeweb
11-
12-
# And run it 👟
13-
npm start
1417
```
1518

16-
## 🚨 Requirements
17-
| Name | Version |
18-
| ---- | ------- |
19-
| [Git](https://git-scm.com) | Any |
20-
| [Node](https://nodejs.org) | Recent |
19+
<br>
20+
21+
### Includes
22+
23+
[Start 🧨](https://github.com/nativew/start) &nbsp;&nbsp; Starter boilerplate for Native Web.
24+
25+
<br><br>
2126

22-
## 🤝 License
23-
[ISC](https://github.com/nativew/build/blob/master/license)
27+
<a href="https://github.com/nativew/nativeweb">
28+
<img src="https://raw.githubusercontent.com/nativew/nativeweb/1e9405c629e3a6491bb59df726044eb3823967bb/logo-square_nativeweb.svg" alt="Native Web" width="80px">
29+
</a>
2430

25-
<p>
2631
<br>
27-
<a href="https://github.com/nativew/create">
28-
<img src="https://raw.githubusercontent.com/nativew/nativeweb/53d4fe591d5992c81b3faeb656fd1aea7aabb413/logo-square.svg?sanitize=true" alt="Native Web" width="50px">
29-
</a>
30-
</p>

src/data.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
const url = 'https://github.com/nativew/start';
1+
export const url = 'https://github.com/nativew/start';
22

3-
const msgs = {
3+
export const msgs = {
44
one: '👋 What’s the name of your project? ',
55
twoStart: '👌 Let’s start ',
6-
twoEnd: '.',
7-
three: '🤙 Ready to go! ',
6+
twoEnd: '',
7+
three: '🤙 Ready to go! Run ',
88
cmdStart: ' cd ',
99
cmdEnd: ' && npm start ',
1010
error: '👎 Try another name?'
1111
};
12-
13-
module.exports = { url, msgs };

src/index.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
#!/usr/bin/env node
2-
const { msgs } = require('./data');
3-
const log = require('./modules/log');
4-
const color = require('./modules/color');
5-
const highlight = require('./modules/highlight');
6-
const clone = require('./modules/clone');
7-
const install = require('./modules/install');
2+
import clone from './modules/clone.js';
3+
import install from './modules/install.js';
4+
import log from './modules/log.js';
5+
import highlight from './modules/highlight.js';
6+
import rl from './modules/rl.js';
7+
import color from './modules/color.js';
8+
import { msgs } from './data.js';
89

9-
// Get argument for name
1010
let name = process.argv[2];
1111

12-
if (name) {
13-
// Has name, start cloning
14-
log(msgs.twoStart + name + msgs.twoEnd);
15-
start();
16-
} else {
17-
// Doesn't have name, ask question
18-
const rl = require('./modules/rl');
12+
const start = () => {
13+
if (clone(name)) {
14+
install(name);
15+
log(msgs.three + highlight(msgs.cmdStart + name + msgs.cmdEnd));
16+
} else {
17+
log(msgs.error);
18+
}
19+
20+
process.exit();
21+
};
1922

20-
rl.question(color(msgs.one), (answer) => {
21-
// Set answer as name & start cloning
23+
const askName = () =>
24+
rl.question(color(msgs.one), answer => {
2225
name = answer;
2326
log(msgs.twoStart + answer + msgs.twoEnd);
2427
rl.close();
2528
start();
2629
});
27-
}
2830

29-
function start() {
30-
if (clone(name)) {
31-
// Clone sucess, install packages
32-
install(name);
33-
log(msgs.three + highlight(msgs.cmdStart + name + msgs.cmdEnd));
34-
} else {
35-
// Clone fail, log error message
36-
log(msgs.error);
37-
}
31+
if (name) {
32+
log(msgs.twoStart + name + msgs.twoEnd);
33+
start();
34+
} else {
35+
askName();
3836
}

src/modules/clone.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
const { url } = require('../data');
2-
const run = require('./run');
1+
import run from './run.js';
2+
import { url } from '../data.js';
33

4-
function clone(dest) {
4+
const clone = dest => {
55
const cmd = run('git', ['clone', '--depth=1', url, dest]);
66

77
if (cmd.status == 0) {
8-
// Delete .git folder
98
run('rm', ['-rf', `${dest}/.git`]);
109
return true;
11-
} else {
12-
return false;
1310
}
14-
}
1511

16-
module.exports = clone;
12+
return false;
13+
};
14+
15+
export default clone;

src/modules/color.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const { yellow, reset } = require('./styles');
1+
import styles from './styles.js';
22

3-
function color(text) {
4-
return yellow + text + reset;
5-
}
3+
const { yellow, reset } = styles;
64

7-
module.exports = color;
5+
const color = text => yellow + text + reset;
6+
7+
export default color;

src/modules/exists.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
const fs = require('fs');
1+
import fs from 'fs';
22

3-
function exists(path) {
4-
return fs.existsSync(path) ? true : false;
5-
}
3+
const exists = path => (fs.existsSync(path) ? true : false);
64

7-
module.exports = exists;
5+
export default exists;

0 commit comments

Comments
 (0)