Skip to content

Commit 07296b4

Browse files
committed
fix: dissolve templateRoot into options
BREAKING CHANGE: all create() must be fixed
1 parent 0b70e03 commit 07296b4

6 files changed

Lines changed: 24 additions & 13 deletions

File tree

src/cli.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ import {resolve} from 'path';
44
import {create} from '.';
55

66
const templateRoot = resolve(__dirname, '../templates');
7-
const caveat = `Inside that directory, you can run several commands:
7+
const caveat = `
8+
Inside that directory, you can run several commands:
89
yarn dev
910
Starts 'tsc -w'.
1011
yarn build
1112
Build the app for production.
13+
14+
Read the doc for the further information:
15+
https://github.com/uetchy/create-whatever/blob/master/README.md
1216
`;
1317

14-
create('create-whatever', templateRoot, {
18+
create('create-whatever', {
19+
templateRoot,
1520
caveat,
1621
});

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface Config {
2626
}
2727

2828
export interface Options {
29+
templateRoot: string;
2930
extra?: Option;
3031
caveat?: string;
3132
after?: () => void;
@@ -129,11 +130,7 @@ async function getYargsOptions(
129130
return yargOption;
130131
}
131132

132-
export async function create(
133-
appName: string,
134-
templateRoot: string,
135-
options: Options = {},
136-
) {
133+
export async function create(appName: string, options: Options) {
137134
try {
138135
const firstArg = process.argv[2];
139136
if (firstArg === undefined) {
@@ -144,6 +141,7 @@ export async function create(
144141
? path.basename(process.cwd())
145142
: firstArg;
146143
const packageDir = useCurrentDir ? process.cwd() : path.resolve(name);
144+
const templateRoot = options.templateRoot;
147145

148146
if (isOccupied(packageDir)) {
149147
throw new Error(`${packageDir} is not empty directory.`);

templates/default/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "{{description}}",
44
"version": "0.0.0",
55
"dependencies": {
6-
"create-whatever": "^4.0.0"
6+
"create-whatever": "^5.0.0"
77
},
88
"author": "{{contact}}",
99
"license": "{{license}}",

templates/default/src/cli.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ const {resolve} = require('path');
44
const {create} = require('create-whatever');
55

66
const templateRoot = resolve(__dirname, '../templates');
7-
const caveat = `This is a caveat!
7+
const caveat = `
8+
This is a caveat!
89
You can find this section in "src/cli.ts".
910
`;
1011

11-
create('{{kebab name}}', templateRoot, {caveat});
12+
create('{{kebab name}}', {
13+
templateRoot,
14+
caveat,
15+
});

templates/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "tsc -w"
88
},
99
"dependencies": {
10-
"create-whatever": "^4.0.0"
10+
"create-whatever": "^5.0.0"
1111
},
1212
"devDependencies": {
1313
"shx": "^0.3.2",

templates/typescript/src/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import {resolve} from 'path';
44
import {create} from 'create-whatever';
55

66
const templateRoot = resolve(__dirname, '../templates');
7-
const caveat = `This is a caveat!
7+
const caveat = `
8+
This is a caveat!
89
You can find this section in "src/cli.ts".
910
`;
1011

11-
create('{{kebab name}}', templateRoot, {caveat});
12+
create('{{kebab name}}', {
13+
templateRoot,
14+
caveat,
15+
});

0 commit comments

Comments
 (0)