Skip to content

Commit 1c32f59

Browse files
committed
Allow pnpm as package manager
1 parent 7b7ab8a commit 1c32f59

File tree

5 files changed

+34
-28
lines changed

5 files changed

+34
-28
lines changed

packages/create-cycle-app/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const validCommands = {
1111
'verbose': true,
1212
'flavor': true,
1313
'yarn': true,
14+
'pnpm': true,
1415
'forceprompt': true
1516
}
1617

@@ -21,7 +22,7 @@ if (commands.length === 0) {
2122
console.log(chalk.green(`create-cycle-app version: ${VERSION}`))
2223
process.exit()
2324
}
24-
console.error(chalk.red('Usage: create-cycle-app <project-directory> [--flavor] [--verbose] [--yarn]'))
25+
console.error(chalk.red('Usage: create-cycle-app <project-directory> [--flavor] [--verbose] [--yarn | --pnpm]'))
2526
process.exit(1)
2627
}
2728

@@ -38,9 +39,9 @@ Object.keys(argv)
3839

3940
const flavor = argv.flavor || 'core'
4041
const verbose = argv.verbose || false
41-
const yarn = argv.yarn || false
42+
const cli = argv.yarn ? 'yarn' : (argv.pnpm ? 'pnpm' : 'npm')
4243
const forceprompt = argv.forceprompt || false
4344
const name = commands[0]
4445

4546
// Parse the command line options and run the setup
46-
createApp(name, verbose, flavor, yarn, forceprompt)
47+
createApp(name, verbose, flavor, cli, forceprompt)

packages/create-cycle-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-cycle-app",
3-
"version": "4.0.0",
3+
"version": "4.1.0-rc.1",
44
"description": "Create Cycle.js with no build configuration.",
55
"scripts": {
66
"test": "jest"

packages/create-cycle-app/src/createApp.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ const installScripts = require('./installScripts')
88
const createPackageJson = require('./createPackageJson')
99
const shouldUseYarn = require('./shouldUseYarn')
1010

11-
module.exports = function createApp (name, verbose, flavor, yarn, forceprompt) {
11+
module.exports = function createApp (name, verbose, flavor, cli, forceprompt) {
1212
// The path where the cycle app will be created
1313
const appPath = path.resolve(name)
1414
// The name of the cycle app to create
1515
const appName = path.basename(appPath)
1616
// Which CLi to use (yarn or npm)
17-
let cli = 'npm'
18-
if (yarn || shouldUseYarn()) {
17+
if (shouldUseYarn()) {
1918
cli = 'yarn'
2019
}
2120
// console.log(cli)

packages/create-cycle-app/src/installScripts.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ module.exports = function installScripts (appFolder, appName, options) {
1717
// Get the right name of the flavor package
1818
const packageName = getPackageName(flavor)
1919
// Install dependencies
20+
const npmArgs = [
21+
'install',
22+
verbose && '--verbose',
23+
'--save-dev',
24+
'--save-exact',
25+
flavor
26+
].filter(a => a)
27+
2028
const args = {
21-
npm: [
22-
'install',
23-
verbose && '--verbose',
24-
'--save-dev',
25-
'--save-exact',
26-
flavor
27-
].filter(a => a),
29+
npm: npmArgs,
30+
pnpm: npmArgs,
2831
yarn: [
2932
'add',
3033
'--exact',
34+
'--dev',
3135
verbose && '--verbose',
3236
local ? 'file:' + flavor : flavor
3337
].filter(a => a)

packages/create-cycle-app/test/integration/__snapshots__/createCycleApp.spec.js.snap

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
13
exports[`create-cycle-app when invoked with the the correct arguments it generate a correct package.json file 1`] = `
24
"{
3-
\"name\": \"MYCYCLEAPP\",
4-
\"version\": \"0.1.0\",
5-
\"private\": true,
6-
\"devDependencies\": {
7-
\"cycle-scripts\": \"1.0.3\"
5+
"name": "MYCYCLEAPP",
6+
"version": "0.1.0",
7+
"private": true,
8+
"devDependencies": {
9+
"cycle-scripts": "1.0.3"
810
},
9-
\"dependencies\": {},
10-
\"scripts\": {
11-
\"start\": \"cycle-scripts start\",
12-
\"test\": \"cycle-scripts test\",
13-
\"build\": \"cycle-scripts build\",
14-
\"eject\": \"cycle-scripts eject\"
11+
"dependencies": {},
12+
"scripts": {
13+
"start": "cycle-scripts start",
14+
"test": "cycle-scripts test",
15+
"build": "cycle-scripts build",
16+
"eject": "cycle-scripts eject"
1517
},
16-
\"babel\": {
17-
\"presets\": [
18-
\"es2015\"
18+
"babel": {
19+
"presets": [
20+
"es2015"
1921
]
2022
}
2123
}"

0 commit comments

Comments
 (0)