@startupjs/cli 0.54.3 → 0.54.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/corepack.sh +55 -0
  2. package/index.js +12 -13
  3. package/package.json +2 -2
package/corepack.sh ADDED
@@ -0,0 +1,55 @@
1
+ #!/bin/bash
2
+
3
+ # Fail script on first failed command
4
+ set -e
5
+
6
+ # function to compare version numbers
7
+ function version_greater_or_equal() {
8
+ [ "$1" == "`echo -e "$1\n$2" | sort -V | tail -n1`" ]
9
+ }
10
+
11
+ function main () {
12
+ # check if 'corepack' exists
13
+ if ! command -v corepack &> /dev/null
14
+ then
15
+ echo "corepack could not be found"
16
+
17
+ read -p "Do you want to install it? (Y/n) " answer
18
+ case ${answer:0:1} in
19
+ y|Y )
20
+ npm i -g corepack@latest
21
+ ;;
22
+ * )
23
+ echo "Aborting the script as per your request."
24
+ exit 1
25
+ ;;
26
+ esac
27
+ fi
28
+
29
+ # check if the version is >=0.20.0
30
+ version=$(corepack --version)
31
+ required_version="0.20.0"
32
+
33
+ if version_greater_or_equal $required_version $version; then
34
+ echo "corepack version is less than ${required_version}"
35
+
36
+ read -p "Would you like to update it now? (Y/n) " answer
37
+ case ${answer:0:1} in
38
+ y|Y )
39
+ npm i -g corepack@latest
40
+ ;;
41
+ * )
42
+ echo "Aborting the script as per your request."
43
+ exit 1
44
+ ;;
45
+ esac
46
+ fi
47
+
48
+ # do 'corepack enable'
49
+ corepack enable
50
+
51
+ # do 'corepack use yarn@4'
52
+ corepack use yarn@"$1"
53
+ }
54
+
55
+ main "$@"; exit
package/index.js CHANGED
@@ -335,7 +335,7 @@ const SCRIPTS = {
335
335
  }
336
336
 
337
337
  const DEFAULT_TEMPLATE = 'ui'
338
- const DEFAULT_YARN_VERSION = '4.0.1'
338
+ const DEFAULT_YARN_VERSION = '4'
339
339
  const TEMPLATES = {
340
340
  simple: {
341
341
  subTemplates: ['simple']
@@ -381,6 +381,16 @@ commander
381
381
  .action(async (projectName, { reactNative, template, yarn }) => {
382
382
  console.log('> run npx', projectName, { reactNative, template, yarn })
383
383
 
384
+ // setup corepack
385
+ try {
386
+ await execa.command(
387
+ `${path.join(__dirname, 'corepack.sh')} ${yarn}`,
388
+ { shell: true }
389
+ )
390
+ } catch (e) {
391
+ console.error(e.stderr)
392
+ }
393
+
384
394
  const projectPath = path.join(process.cwd(), LOCAL_DIR, projectName)
385
395
 
386
396
  // check if template exists
@@ -414,19 +424,10 @@ commander
414
424
  })
415
425
  }
416
426
 
417
- // specify yarn version
418
- await execa('yarn', ['set', 'version', yarn], {
419
- cwd: projectPath,
420
- stdio: 'inherit'
421
- })
422
427
  await execa('yarn', ['config', 'set', 'nodeLinker', 'node-modules'], {
423
428
  cwd: projectPath,
424
429
  stdio: 'inherit'
425
430
  })
426
- await execa('yarn', ['config', 'set', 'enableGlobalCache', false], {
427
- cwd: projectPath,
428
- stdio: 'inherit'
429
- })
430
431
 
431
432
  // remove extra dependencies which are covered by startupjs core
432
433
  if (REMOVE_DEPENDENCIES.length) {
@@ -746,9 +747,7 @@ function appendGitignore (projectPath) {
746
747
  # Mongo data when running in a docker dev container
747
748
  /.mongo
748
749
  # yarn
749
- .yarn/*
750
- !.yarn/releases
751
- !.yarn/cache
750
+ .yarn/
752
751
  `.replace(/\n\s+/g, '\n')
753
752
 
754
753
  fs.writeFileSync(gitignorePath, gitignore)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startupjs/cli",
3
- "version": "0.54.3",
3
+ "version": "0.54.7",
4
4
  "description": "start, watch and build startupjs project",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -25,5 +25,5 @@
25
25
  "webpack-cli": "^4.9.1",
26
26
  "webpack-dev-server": "^4.4.0"
27
27
  },
28
- "gitHead": "208b1eb50e749d344be1c24d446ab0fceea4b33b"
28
+ "gitHead": "7482d5c9d3b425fdd75a511a338c485ffbefb9da"
29
29
  }