Skip to content

Commit 7b5b99f

Browse files
committed
templates
1 parent e8121c8 commit 7b5b99f

35 files changed

+610
-65
lines changed

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"--no-lockfile"
88
],
99
"packages": [
10-
"packages/*"
10+
"packages/*",
11+
"templates/*"
1112
],
1213
"version": "independent",
1314
"registry": "https://registry.npmjs.org",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"prettier": "2.7.0"
2929
},
3030
"workspaces": [
31-
"packages/*"
31+
"packages/*",
32+
"templates/*"
3233
],
3334
"repository": {
3435
"type": "git",

packages/create-cosmos-app/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
},
8383
"dependencies": {
8484
"@babel/runtime": "^7.11.2",
85-
"@pyramation/prompt": "0.1.1",
86-
"dargs": "8.1.0",
85+
"dargs": "7.0.0",
8786
"fuzzy": "0.1.3",
8887
"inquirerer": "0.1.3",
8988
"minimist": "1.2.6",

packages/create-cosmos-app/scripts/build-cmds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ const makeCommands = (folder) => {
4949
return out;
5050
};
5151

52-
fs.writeFileSync(`${__dirname}/../src/cmds.js`, makeCommands('commands'));
52+
fs.writeFileSync(`${__dirname}/../src/cmds.js`, makeCommands('templates'));

packages/create-cosmos-app/src/cli.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prompt } from './prompt';
2-
import { Commands as commands } from './cmds';
2+
import { Templates as templates } from './cmds';
33

44
export const cli = async (argv) => {
55
const { cmd } = await prompt(
@@ -9,13 +9,14 @@ export const cli = async (argv) => {
99
type: 'fuzzy',
1010
name: 'cmd',
1111
message: 'what do you want to create?',
12-
choices: Object.keys(commands)
12+
choices: Object.keys(templates)
1313
}
1414
],
1515
argv
1616
);
17-
if (typeof commands[cmd] === 'function') {
18-
await commands[cmd](argv);
17+
if (typeof templates[cmd] === 'function') {
18+
console.log(`calling ${cmd}`)
19+
await templates[cmd](argv);
1920
} else {
2021
console.log('command not found.');
2122
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

2-
3-
const Commands = {};
4-
5-
6-
export { Commands };
7-
8-
2+
import _templates_typescript_npm_module from './templates/typescript-npm-module';
3+
const Templates = {};
4+
Templates['typescript-npm-module'] = _templates_typescript_npm_module;
5+
6+
export { Templates };
7+

packages/create-cosmos-app/src/create-cosmos-app.ts

100644100755
File mode changed.

packages/create-cosmos-app/src/template.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
21
import * as shell from 'shelljs';
3-
import { prompt } from '@pyramation/prompt';
4-
import dargs from 'dargs';
2+
import { prompt } from './prompt';
3+
const dargs = require('dargs');
54
const glob = require('glob').sync;
65
const fs = require('fs');
76
const path = require('path');
87

98
export const createApp = (repo: string) => {
10-
const clone = async argv => {
9+
return async argv => {
10+
const { name } = await prompt([
11+
{
12+
name: 'name',
13+
message: 'Enter your new module name',
14+
required: true,
15+
}
16+
], argv);
17+
1118
if (!shell.which('git')) {
1219
shell.echo('Sorry, this script requires git');
1320
return shell.exit(1);
1421
}
1522

16-
const { name } = argv;
17-
1823
shell.exec(`git clone ${repo} ${name}`);
1924
shell.cd(name);
2025

@@ -124,21 +129,12 @@ export const createApp = (repo: string) => {
124129
shell.rm('-rf', '.questions.json');
125130

126131
console.log(`
127-
132+
128133
|||
129134
(o o)
130135
ooO--(_)--Ooo-
131-
136+
132137
✨ Great work!
133138
`);
134139
};
135-
136-
clone.questions = [
137-
{
138-
name: 'name',
139-
message: 'Enter your new module name',
140-
required: true,
141-
}
142-
];
143-
144140
};

packages/create-cosmos-app/src/templates/create-cosmos-app.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createApp } from "../template";
2+
3+
export default createApp('[email protected]:supercosmonauts/cca-ts-module.git');

0 commit comments

Comments
 (0)