Browse Source

refactor: use yarn during npm install process

NGPixel 7 năm trước cách đây
mục cha
commit
4b027b137b
3 tập tin đã thay đổi với 23 bổ sung2 xóa
  1. 3 0
      CHANGELOG.md
  2. 16 1
      npm/install.js
  3. 4 1
      tsconfig.json

+ 3 - 0
CHANGELOG.md

@@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - **Security**: Optional Two-Factor Authentication (2FA) protection
 
 ## [v1.0.0-beta.14] - Unreleased
+### Changed
+- **Misc**: Switch to Yarn for npm dependencies installation
+
 ### Fixed
 - **Misc**: JS/CSS is now loading properly in Safari (macOS/iOS)
 - **Misc**: Process termination handling

+ 16 - 1
npm/install.js

@@ -138,12 +138,24 @@ const tasks = {
       }
     })
   },
+  /**
+   * Install Yarn
+   */
+  installYarn() {
+    ora.text = 'Installing Yarn...'
+    return exec.stdout('npm', ['install', '-g', 'yarn'], {
+      cwd: installDir
+    }).then(results => {
+      ora.text = 'Yarn installed successfully.'
+      return true
+    })
+  },
   /**
    * Install npm dependencies
    */
   installDependencies() {
     ora.text = 'Installing Wiki.js npm dependencies...'
-    return exec.stdout('npm', ['install', '--only=production', '--no-optional'], {
+    return exec.stdout('yarn', ['install', '--production', '--ignore-optional'], {
       cwd: installDir
     }).then(results => {
       ora.text = 'Wiki.js npm dependencies installed successfully.'
@@ -247,6 +259,9 @@ Promise.join(
 }).then(() => {
   isContainerBased && console.info('>> Creating config file...')
   return tasks.ensureConfigFile()
+}).then(() => {
+  isContainerBased && console.info('>> Installing Yarn...')
+  return tasks.installYarn()
 }).then(() => {
   isContainerBased && console.info('>> Installing dependencies...')
   return tasks.installDependencies()

+ 4 - 1
tsconfig.json

@@ -11,5 +11,8 @@
     "strictNullChecks": true,
     "suppressImplicitAnyIndexErrors": true,
     "target": "es5"
-  }
+  },
+  "exclude": [
+    "node_modules"
+  ]
 }