-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
executable file
·47 lines (41 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
import {$} from 'execa';
import {fileURLToPath} from 'node:url';
import path from 'node:path';
import {Scaffold as scaffold} from 'simple-scaffold';
const cwd = process.cwd();
const base = path.basename(cwd);
const parent = path.basename(path.dirname(cwd));
const org = parent.startsWith('@') ? parent : '';
const name = org ? `${parent}/${base}` : base;
const {stdout: ujson} = await $`gh api https://api.github.com/user`;
const {
name: author,
email,
...user
} = JSON.parse(ujson);
const login = org ? org.slice(1).replaceAll('.', '-') : user.login;
const templates = [fileURLToPath(new URL('./template', import.meta.url))];
await scaffold({
base,
name,
templates,
data: {
author,
base,
email,
login,
user: user.login,
npmignore: '.npmignore',
gitignore: '.gitignore',
gitattributes: '.gitattributes',
},
});
const v = {verbose: 'full'};
await $(v)`ncu -u`;
await $(v)`pnpm install`;
await $(v)`git init .`;
await $(v)`git add .`;
await $(v)`git ci -m ${'Initial checkin'}`;
await $(v)`npm run build`;
await $(v)`gh secret set NPM_TOKEN`;