mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 07:47:20 +00:00 
			
		
		
		
	Compare commits
	
		
			22 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | eeb10cff27 | ||
|   | ed1a46e9f2 | ||
|   | daff393d43 | ||
|   | b14573ddb9 | ||
|   | 7569de03e7 | ||
|   | b20a2561b9 | ||
|   | ea3459bb45 | ||
|   | 141334fcd1 | ||
|   | 808c8f917f | ||
|   | fd1b409bc3 | ||
|   | 9a03ebd9cc | ||
|   | 45e544a71a | ||
|   | 8c66f89aef | ||
|   | 3601f2a33e | ||
|   | 4d62fafc05 | ||
|   | 17f8bd9264 | ||
|   | b067f78ed3 | ||
|   | 0bd06765ef | ||
|   | 25184c4485 | ||
|   | 337fdf2194 | ||
|   | 86bf502a33 | ||
|   | 146c4d84a5 | 
							
								
								
									
										41
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							| @@ -35,13 +35,21 @@ jobs: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*] | ||||
|         node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|       - name: Setup Node | ||||
|         uses: ./ | ||||
|         with: | ||||
|           node-version: ${{ matrix.node-version }} | ||||
|           check-latest: true | ||||
|       - if: runner.os != 'Windows' | ||||
|         name: Verify node and npm | ||||
|         run: | | ||||
|           . "$NVM_DIR/nvm.sh" | ||||
|           [[ $(nvm version-remote "${{ matrix.node-version }}") =~ ^v([^.]+) ]] | ||||
|           __tests__/verify-node.sh "${BASH_REMATCH[1]}" | ||||
|         shell: bash | ||||
|  | ||||
|   manifest: | ||||
|     runs-on: ${{ matrix.os }} | ||||
| @@ -139,3 +147,34 @@ jobs: | ||||
|       - name: Verify node | ||||
|         run: __tests__/verify-arch.sh "ia32" | ||||
|         shell: bash | ||||
|  | ||||
|   node-latest-aliases: | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, windows-latest, macos-latest] | ||||
|         node-version: [current, latest, node] | ||||
|     steps: | ||||
|       - name: Get node version | ||||
|         run: | | ||||
|           latestNodeVersion=$(curl https://nodejs.org/dist/index.json | jq -r '. [0].version') | ||||
|           echo "::set-output name=LATEST_NODE_VERSION::$latestNodeVersion" | ||||
|         id: version | ||||
|         shell: bash | ||||
|       - uses: actions/checkout@v3 | ||||
|       - name: Setup Node | ||||
|         uses: ./ | ||||
|         with: | ||||
|           node-version: ${{ matrix.node-version }} | ||||
|       - name: Retrieve version after install | ||||
|         run: | | ||||
|           updatedVersion=$(echo $(node --version)) | ||||
|           echo "::set-output name=NODE_VERSION_UPDATED::$updatedVersion" | ||||
|         id: updatedVersion | ||||
|         shell: bash | ||||
|       - name: Compare versions | ||||
|         if: ${{ steps.version.outputs.LATEST_NODE_VERSION != steps.updatedVersion.outputs.NODE_VERSION_UPDATED}} | ||||
|         run: | | ||||
|           echo "Latest node version failed to download." | ||||
|           exit 1 | ||||
|   | ||||
							
								
								
									
										51
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								README.md
									
									
									
									
									
								
							| @@ -11,7 +11,7 @@ This action provides the following functionality for GitHub Actions users: | ||||
| - Registering problem matchers for error output | ||||
| - Configuring authentication for GPR or npm | ||||
|  | ||||
| # Usage | ||||
| ## Usage | ||||
|  | ||||
| See [action.yml](action.yml) | ||||
|  | ||||
| @@ -22,8 +22,8 @@ steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/setup-node@v3 | ||||
|   with: | ||||
|     node-version: '14' | ||||
| - run: npm install | ||||
|     node-version: 14 | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -33,21 +33,30 @@ The action will first check the local cache for a semver match. If unable to fin | ||||
|  | ||||
| For information regarding locally cached versions of Node.js on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). | ||||
|  | ||||
| #### Supported version syntax | ||||
| ### Supported version syntax | ||||
|  | ||||
| The `node-version` input supports the following syntax: | ||||
| The `node-version` input supports the following values: | ||||
|  | ||||
| major versions: `12`, `14`, `16` | ||||
| more specific versions: `10.15`, `14.2.0`, `16.3.0` | ||||
| nvm lts syntax: `lts/erbium`, `lts/fermium`, `lts/*` | ||||
|  - Major versions: `12`, `14`, `16` | ||||
|  - More specific versions: `10.15`, `14.2.0`, `16.3.0` | ||||
|  - NVM LTS syntax: `lts/erbium`, `lts/fermium`, `lts/*`, `lts/-n` | ||||
|  - Latest release: `latest`/`current`/`node` | ||||
|  | ||||
| ## Caching packages dependencies | ||||
| **Note:** Since the latest release will not be cached always, there is possibility of hitting rate limit when downloading from dist | ||||
|  | ||||
| The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default. | ||||
| ### Checking in lockfiles | ||||
|  | ||||
| It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide. | ||||
|  | ||||
| ## Caching global packages data | ||||
|  | ||||
| The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default. | ||||
|  | ||||
| The action defaults to search for the dependency file (`package-lock.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories. | ||||
|  | ||||
| See the examples of using cache for `yarn` / `pnpm` and  `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-dependencies) guide. | ||||
| **Note:** The action does not cache `node_modules` | ||||
|  | ||||
| See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-data) guide. | ||||
|  | ||||
| **Caching npm dependencies:** | ||||
|  | ||||
| @@ -56,9 +65,9 @@ steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/setup-node@v3 | ||||
|   with: | ||||
|     node-version: '14' | ||||
|     node-version: 14 | ||||
|     cache: 'npm' | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -69,14 +78,14 @@ steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: actions/setup-node@v3 | ||||
|   with: | ||||
|     node-version: '14' | ||||
|     node-version: 14 | ||||
|     cache: 'npm' | ||||
|     cache-dependency-path: subdir/package-lock.json | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| ## Matrix Testing: | ||||
| ## Matrix Testing | ||||
|  | ||||
| ```yaml | ||||
| jobs: | ||||
| @@ -84,7 +93,7 @@ jobs: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         node: [ '12', '14', '16' ] | ||||
|         node: [ 12, 14, 16 ] | ||||
|     name: Node ${{ matrix.node }} sample | ||||
|     steps: | ||||
|       - uses: actions/checkout@v3 | ||||
| @@ -92,7 +101,7 @@ jobs: | ||||
|         uses: actions/setup-node@v3 | ||||
|         with: | ||||
|           node-version: ${{ matrix.node }} | ||||
|       - run: npm install | ||||
|       - run: npm ci | ||||
|       - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -101,17 +110,17 @@ jobs: | ||||
| 1. [Check latest version](docs/advanced-usage.md#check-latest-version) | ||||
| 2. [Using a node version file](docs/advanced-usage.md#node-version-file) | ||||
| 3. [Using different architectures](docs/advanced-usage.md#architecture) | ||||
| 4. [Caching packages dependencies](docs/advanced-usage.md#caching-packages-dependencies) | ||||
| 4. [Caching packages data](docs/advanced-usage.md#caching-packages-data) | ||||
| 5. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures) | ||||
| 6. [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm) | ||||
| 7. [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn) | ||||
| 8. [Using private packages](docs/advanced-usage.md#use-private-packages) | ||||
|  | ||||
| # License | ||||
| ## License | ||||
|  | ||||
| The scripts and documentation in this project are released under the [MIT License](LICENSE) | ||||
|  | ||||
| # Contributions | ||||
| ## Contributions | ||||
|  | ||||
| Contributions are welcome! See [Contributor's Guide](docs/contributors.md) | ||||
|  | ||||
|   | ||||
| @@ -3,50 +3,50 @@ | ||||
|     "version": "14.0.0", | ||||
|     "stable": true, | ||||
|     "lts": "Fermium", | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200423.30", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200507.99", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-14.0.0-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-14.0.0-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-14.0.0-win32-x64.zip", | ||||
|         "filename": "node-14.0.0-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
|   { | ||||
|     "version": "13.13.0", | ||||
|     "stable": true, | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200423.29", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200507.97", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-13.13.0-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-13.13.0-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-13.13.0-win32-x64.zip", | ||||
|         "filename": "node-13.13.0-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200423.29/node-13.13.0-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
| @@ -54,25 +54,51 @@ | ||||
|     "version": "12.16.2", | ||||
|     "stable": true, | ||||
|     "lts": "Erbium", | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200423.28", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200507.95", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-12.16.2-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-12.16.2-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-12.16.2-win32-x64.zip", | ||||
|         "filename": "node-12.16.2-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
|   { | ||||
|     "version": "12.0.0", | ||||
|     "stable": true, | ||||
|     "lts": "Erbium", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/12.0.0-20200507.71", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-12.0.0-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-12.0.0-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-12.0.0-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
| @@ -80,25 +106,25 @@ | ||||
|     "version": "10.20.1", | ||||
|     "stable": true, | ||||
|     "lts": "Dubnium", | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200423.27", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200507.70", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-10.20.1-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-10.20.1-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-10.20.1-win32-x64.zip", | ||||
|         "filename": "node-10.20.1-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200423.27/node-10.20.1-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
| @@ -106,25 +132,25 @@ | ||||
|     "version": "8.17.0", | ||||
|     "stable": true, | ||||
|     "lts": "Carbon", | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200423.26", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200507.37", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-8.17.0-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-8.17.0-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-8.17.0-win32-x64.zip", | ||||
|         "filename": "node-8.17.0-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200423.26/node-8.17.0-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
| @@ -132,26 +158,26 @@ | ||||
|     "version": "6.17.1", | ||||
|     "stable": true, | ||||
|     "lts": "Boron", | ||||
|       "release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200423.25", | ||||
|     "release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200529.2", | ||||
|     "files": [ | ||||
|       { | ||||
|         "filename": "node-6.17.1-darwin-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "darwin", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-darwin-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-darwin-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|         "filename": "node-6.17.1-linux-x64.tar.gz", | ||||
|         "arch": "x64", | ||||
|         "platform": "linux", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-linux-x64.tar.gz" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-linux-x64.tar.gz" | ||||
|       }, | ||||
|       { | ||||
|           "filename": "node-6.17.1-win32-x64.zip", | ||||
|         "filename": "node-6.17.1-win32-x64.7z", | ||||
|         "arch": "x64", | ||||
|         "platform": "win32", | ||||
|           "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200423.25/node-6.17.1-win32-x64.zip" | ||||
|         "download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-win32-x64.7z" | ||||
|       } | ||||
|     ] | ||||
|   } | ||||
|   ] | ||||
| ] | ||||
|   | ||||
| @@ -126,7 +126,7 @@ describe('setup-node', () => { | ||||
|       'mocktoken' | ||||
|     ); | ||||
|     expect(versions).toBeDefined(); | ||||
|     expect(versions?.length).toBe(6); | ||||
|     expect(versions?.length).toBe(7); | ||||
|   }); | ||||
|  | ||||
|   it('can mock dist versions', async () => { | ||||
| @@ -135,8 +135,15 @@ describe('setup-node', () => { | ||||
|     expect(versions?.length).toBe(23); | ||||
|   }); | ||||
|  | ||||
|   it('can find 12.16.2 from manifest on osx', async () => { | ||||
|     os.platform = 'darwin'; | ||||
|   it.each([ | ||||
|     ['12.16.2', 'darwin', '12.16.2', 'Erbium'], | ||||
|     ['12', 'linux', '12.16.2', 'Erbium'], | ||||
|     ['10', 'win32', '10.20.1', 'Dubnium'], | ||||
|     ['*', 'linux', '14.0.0', 'Fermium'] | ||||
|   ])( | ||||
|     'can find %s from manifest on %s', | ||||
|     async (versionSpec, platform, expectedVersion, expectedLts) => { | ||||
|       os.platform = platform; | ||||
|       os.arch = 'x64'; | ||||
|       let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo( | ||||
|         'actions', | ||||
| @@ -144,41 +151,12 @@ describe('setup-node', () => { | ||||
|         'mocktoken' | ||||
|       ); | ||||
|       expect(versions).toBeDefined(); | ||||
|     let match = await tc.findFromManifest('12.16.2', true, versions); | ||||
|       let match = await tc.findFromManifest(versionSpec, true, versions); | ||||
|       expect(match).toBeDefined(); | ||||
|     expect(match?.version).toBe('12.16.2'); | ||||
|     expect((match as any).lts).toBe('Erbium'); | ||||
|   }); | ||||
|  | ||||
|   it('can find 12 from manifest on linux', async () => { | ||||
|     os.platform = 'linux'; | ||||
|     os.arch = 'x64'; | ||||
|     let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo( | ||||
|       'actions', | ||||
|       'node-versions', | ||||
|       'mocktoken' | ||||
|       expect(match?.version).toBe(expectedVersion); | ||||
|       expect((match as any).lts).toBe(expectedLts); | ||||
|     } | ||||
|   ); | ||||
|     expect(versions).toBeDefined(); | ||||
|     let match = await tc.findFromManifest('12.16.2', true, versions); | ||||
|     expect(match).toBeDefined(); | ||||
|     expect(match?.version).toBe('12.16.2'); | ||||
|     expect((match as any).lts).toBe('Erbium'); | ||||
|   }); | ||||
|  | ||||
|   it('can find 10 from manifest on windows', async () => { | ||||
|     os.platform = 'win32'; | ||||
|     os.arch = 'x64'; | ||||
|     let versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo( | ||||
|       'actions', | ||||
|       'node-versions', | ||||
|       'mocktoken' | ||||
|     ); | ||||
|     expect(versions).toBeDefined(); | ||||
|     let match = await tc.findFromManifest('10', true, versions); | ||||
|     expect(match).toBeDefined(); | ||||
|     expect(match?.version).toBe('10.20.1'); | ||||
|     expect((match as any).lts).toBe('Dubnium'); | ||||
|   }); | ||||
|  | ||||
|   //-------------------------------------------------- | ||||
|   // Found in cache tests | ||||
| @@ -250,7 +228,7 @@ describe('setup-node', () => { | ||||
|     inputs['token'] = 'faketoken'; | ||||
|  | ||||
|     let expectedUrl = | ||||
|       'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; | ||||
|       'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'; | ||||
|  | ||||
|     // ... but not in the local cache | ||||
|     findSpy.mockImplementation(() => ''); | ||||
| @@ -288,7 +266,7 @@ describe('setup-node', () => { | ||||
|     inputs['token'] = 'faketoken'; | ||||
|  | ||||
|     let expectedUrl = | ||||
|       'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; | ||||
|       'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'; | ||||
|  | ||||
|     // ... but not in the local cache | ||||
|     findSpy.mockImplementation(() => ''); | ||||
| @@ -457,7 +435,7 @@ describe('setup-node', () => { | ||||
|       exSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||
|       cacheSpy.mockImplementation(async () => toolPath); | ||||
|       const expectedUrl = | ||||
|         'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; | ||||
|         'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'; | ||||
|  | ||||
|       await main.run(); | ||||
|  | ||||
| @@ -699,11 +677,17 @@ describe('setup-node', () => { | ||||
|       inputs.stable = 'true'; | ||||
|     }); | ||||
|  | ||||
|     it('find latest LTS version and resolve it from local cache (lts/erbium)', async () => { | ||||
|     it.each([ | ||||
|       ['erbium', '12.16.2'], | ||||
|       ['*', '14.0.0'], | ||||
|       ['-1', '12.16.2'] | ||||
|     ])( | ||||
|       'find latest LTS version and resolve it from local cache (lts/%s)', | ||||
|       async (lts, expectedVersion) => { | ||||
|         // arrange | ||||
|       inputs['node-version'] = 'lts/erbium'; | ||||
|         inputs['node-version'] = `lts/${lts}`; | ||||
|  | ||||
|       const toolPath = path.normalize('/cache/node/12.16.2/x64'); | ||||
|         const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`); | ||||
|         findSpy.mockReturnValue(toolPath); | ||||
|  | ||||
|         // act | ||||
| @@ -718,28 +702,46 @@ describe('setup-node', () => { | ||||
|         ); | ||||
|         expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached'); | ||||
|         expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `LTS alias 'erbium' for Node version 'lts/erbium'` | ||||
|           `LTS alias '${lts}' for Node version 'lts/${lts}'` | ||||
|         ); | ||||
|         expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `Found LTS release '12.16.2' for Node version 'lts/erbium'` | ||||
|           `Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'` | ||||
|         ); | ||||
|         expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|         expect(cnSpy).toHaveBeenCalledWith( | ||||
|           `::add-path::${path.join(toolPath, 'bin')}${osm.EOL}` | ||||
|         ); | ||||
|     }); | ||||
|       } | ||||
|     ); | ||||
|  | ||||
|     it('find latest LTS version and install it from manifest (lts/erbium)', async () => { | ||||
|     it.each([ | ||||
|       [ | ||||
|         'erbium', | ||||
|         '12.16.2', | ||||
|         'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz' | ||||
|       ], | ||||
|       [ | ||||
|         '*', | ||||
|         '14.0.0', | ||||
|         'https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz' | ||||
|       ], | ||||
|       [ | ||||
|         '-1', | ||||
|         '12.16.2', | ||||
|         'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz' | ||||
|       ] | ||||
|     ])( | ||||
|       'find latest LTS version and install it from manifest (lts/%s)', | ||||
|       async (lts, expectedVersion, expectedUrl) => { | ||||
|         // arrange | ||||
|       inputs['node-version'] = 'lts/erbium'; | ||||
|         inputs['node-version'] = `lts/${lts}`; | ||||
|  | ||||
|       const toolPath = path.normalize('/cache/node/12.16.2/x64'); | ||||
|         const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`); | ||||
|         findSpy.mockImplementation(() => ''); | ||||
|         dlSpy.mockImplementation(async () => '/some/temp/path'); | ||||
|         exSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||
|         cacheSpy.mockImplementation(async () => toolPath); | ||||
|       const expectedUrl = | ||||
|         'https://github.com/actions/node-versions/releases/download/12.16.2-20200423.28/node-12.16.2-linux-x64.tar.gz'; | ||||
|         const expectedMajor = expectedVersion.split('.')[0]; | ||||
|  | ||||
|         // act | ||||
|         await main.run(); | ||||
| @@ -753,91 +755,24 @@ describe('setup-node', () => { | ||||
|         ); | ||||
|         expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached'); | ||||
|         expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `LTS alias 'erbium' for Node version 'lts/erbium'` | ||||
|           `LTS alias '${lts}' for Node version 'lts/${lts}'` | ||||
|         ); | ||||
|         expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `Found LTS release '12.16.2' for Node version 'lts/erbium'` | ||||
|           `Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'` | ||||
|         ); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempting to download 12...'); | ||||
|         expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Acquiring 12.16.2 - ${os.arch} from ${expectedUrl}` | ||||
|           `Attempting to download ${expectedMajor}...` | ||||
|         ); | ||||
|         expect(logSpy).toHaveBeenCalledWith( | ||||
|           `Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}` | ||||
|         ); | ||||
|         expect(logSpy).toHaveBeenCalledWith('Extracting ...'); | ||||
|         expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); | ||||
|         expect(cnSpy).toHaveBeenCalledWith( | ||||
|           `::add-path::${path.join(toolPath, 'bin')}${osm.EOL}` | ||||
|         ); | ||||
|     }); | ||||
|  | ||||
|     it('find latest LTS version and resolve it from local cache (lts/*)', async () => { | ||||
|       // arrange | ||||
|       inputs['node-version'] = 'lts/*'; | ||||
|  | ||||
|       const toolPath = path.normalize('/cache/node/14.0.0/x64'); | ||||
|       findSpy.mockReturnValue(toolPath); | ||||
|  | ||||
|       // act | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Attempt to resolve LTS alias from manifest...' | ||||
|       } | ||||
|     ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         'Getting manifest from actions/node-versions@main' | ||||
|       ); | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached'); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `LTS alias '*' for Node version 'lts/*'` | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `Found LTS release '14.0.0' for Node version 'lts/*'` | ||||
|       ); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|       expect(cnSpy).toHaveBeenCalledWith( | ||||
|         `::add-path::${path.join(toolPath, 'bin')}${osm.EOL}` | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|     it('find latest LTS version and install it from manifest (lts/*)', async () => { | ||||
|       // arrange | ||||
|       inputs['node-version'] = 'lts/*'; | ||||
|  | ||||
|       const toolPath = path.normalize('/cache/node/14.0.0/x64'); | ||||
|       findSpy.mockImplementation(() => ''); | ||||
|       dlSpy.mockImplementation(async () => '/some/temp/path'); | ||||
|       exSpy.mockImplementation(async () => '/some/other/temp/path'); | ||||
|       cacheSpy.mockImplementation(async () => toolPath); | ||||
|       const expectedUrl = | ||||
|         'https://github.com/actions/node-versions/releases/download/14.0.0-20200423.30/node-14.0.0-linux-x64.tar.gz'; | ||||
|  | ||||
|       // act | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Attempt to resolve LTS alias from manifest...' | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         'Getting manifest from actions/node-versions@main' | ||||
|       ); | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached'); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `LTS alias '*' for Node version 'lts/*'` | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith( | ||||
|         `Found LTS release '14.0.0' for Node version 'lts/*'` | ||||
|       ); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempting to download 14...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Acquiring 14.0.0 - ${os.arch} from ${expectedUrl}` | ||||
|       ); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Extracting ...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); | ||||
|       expect(cnSpy).toHaveBeenCalledWith( | ||||
|         `::add-path::${path.join(toolPath, 'bin')}${osm.EOL}` | ||||
|       ); | ||||
|     }); | ||||
|  | ||||
|     it('fail with unable to parse LTS alias (lts/)', async () => { | ||||
|       // arrange | ||||
| @@ -909,4 +844,57 @@ describe('setup-node', () => { | ||||
|       ); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('latest alias syntax', () => { | ||||
|     it.each(['latest', 'current', 'node'])( | ||||
|       'download the %s version if alias is provided', | ||||
|       async inputVersion => { | ||||
|         // Arrange | ||||
|         inputs['node-version'] = inputVersion; | ||||
|  | ||||
|         os.platform = 'darwin'; | ||||
|         os.arch = 'x64'; | ||||
|  | ||||
|         findSpy.mockImplementation(() => ''); | ||||
|         getManifestSpy.mockImplementation(() => { | ||||
|           throw new Error('Unable to download manifest'); | ||||
|         }); | ||||
|  | ||||
|         // Act | ||||
|         await main.run(); | ||||
|  | ||||
|         // assert | ||||
|         expect(logSpy).toHaveBeenCalledWith('Unable to download manifest'); | ||||
|  | ||||
|         expect(logSpy).toHaveBeenCalledWith('getting latest node version...'); | ||||
|       } | ||||
|     ); | ||||
|   }); | ||||
|  | ||||
|   describe('latest alias syntax from cache', () => { | ||||
|     it.each(['latest', 'current', 'node'])( | ||||
|       'download the %s version if alias is provided', | ||||
|       async inputVersion => { | ||||
|         // Arrange | ||||
|         inputs['node-version'] = inputVersion; | ||||
|         const expectedVersion = nodeTestDist[0]; | ||||
|  | ||||
|         os.platform = 'darwin'; | ||||
|         os.arch = 'x64'; | ||||
|  | ||||
|         const toolPath = path.normalize( | ||||
|           `/cache/node/${expectedVersion.version}/x64` | ||||
|         ); | ||||
|         findSpy.mockReturnValue(toolPath); | ||||
|  | ||||
|         // Act | ||||
|         await main.run(); | ||||
|  | ||||
|         // assert | ||||
|         expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|  | ||||
|         expect(logSpy).toHaveBeenCalledWith('getting latest node version...'); | ||||
|       } | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
							
								
								
									
										18
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								action.yml
									
									
									
									
									
								
							| @@ -1,35 +1,35 @@ | ||||
| name: 'Setup Node.js environment' | ||||
| description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH' | ||||
| description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.' | ||||
| author: 'GitHub' | ||||
| inputs: | ||||
|   always-auth: | ||||
|     description: 'Set always-auth in npmrc' | ||||
|     description: 'Set always-auth in npmrc.' | ||||
|     default: 'false' | ||||
|   node-version: | ||||
|     description: 'Version Spec of the version to use.  Examples: 12.x, 10.15.1, >=10.15.0' | ||||
|     description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' | ||||
|   node-version-file: | ||||
|     description: 'File containing the version Spec of the version to use.  Examples: .nvmrc, .node-version' | ||||
|     description: 'File containing the version Spec of the version to use.  Examples: .nvmrc, .node-version.' | ||||
|   architecture: | ||||
|     description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.' | ||||
|   check-latest: | ||||
|     description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec' | ||||
|     description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec.' | ||||
|     default: false | ||||
|   registry-url: | ||||
|     description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN' | ||||
|     description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.' | ||||
|   scope: | ||||
|     description: 'Optional scope for authenticating against scoped registries' | ||||
|     description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).' | ||||
|   token: | ||||
|     description: Used to pull node distributions from node-versions.  Since there's a default, this is typically not supplied by the user. | ||||
|     default: ${{ github.token }} | ||||
|   cache: | ||||
|     description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm' | ||||
|     description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.' | ||||
|   cache-dependency-path: | ||||
|     description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.' | ||||
| # TODO: add input to control forcing to pull from cloud or dist.  | ||||
| #       escape valve for someone having issues or needing the absolute latest which isn't cached yet | ||||
| outputs: | ||||
|   cache-hit:  | ||||
|     description: 'A boolean value to indicate if a cache was hit' | ||||
|     description: 'A boolean value to indicate if a cache was hit.' | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   main: 'dist/setup/index.js' | ||||
|   | ||||
							
								
								
									
										54965
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										54965
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										74745
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										74745
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -1,4 +1,39 @@ | ||||
| # Advanced usage | ||||
| ## Working with lockfiles | ||||
|  | ||||
| All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits: | ||||
|  | ||||
| - Enables faster installation for CI and production environments, due to being able to skip package resolution. | ||||
| - Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies. | ||||
| - Provides a facility for users to "time-travel" to previous states of `node_modules` without having to commit the directory itself. | ||||
| - Facilitates greater visibility of tree changes through readable source control diffs. | ||||
|  | ||||
| In order to get the most out of using your lockfile on continuous integration follow the conventions outlined below for your respective package manager. | ||||
|  | ||||
| ### NPM | ||||
|  | ||||
| Ensure that `package-lock.json` is always committed, use `npm ci` instead of `npm install` when installing packages. | ||||
|  | ||||
| **See also:** | ||||
| - [Documentation of `package-lock.json`](https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json) | ||||
| - [Documentation of `npm ci`](https://docs.npmjs.com/cli/v8/commands/npm-ci) | ||||
|  | ||||
| ### Yarn | ||||
|  | ||||
| To ensure that `yarn.lock` is always committed, use `yarn install --immutable` when installing packages. | ||||
|  | ||||
| **See also:** | ||||
| - [Documentation of `yarn.lock`](https://classic.yarnpkg.com/en/docs/yarn-lock) | ||||
| - [Documentation of `--frozen-lockfile` option](https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-frozen-lockfile) | ||||
| - [QA - Should lockfiles be committed to the repoistory?](https://yarnpkg.com/getting-started/qa/#should-lockfiles-be-committed-to-the-repository) | ||||
| - [Documentation of `yarn install`](https://yarnpkg.com/cli/install) | ||||
|  | ||||
| ### PNPM | ||||
|  | ||||
| Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lockfile` to `pnpm install` when installing packages. | ||||
|  | ||||
| **See also:** | ||||
| - [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles) | ||||
| - [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile) | ||||
|  | ||||
| ## Check latest version | ||||
|  | ||||
| @@ -15,7 +50,7 @@ steps: | ||||
|   with: | ||||
|     node-version: '14' | ||||
|     check-latest: true | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -31,7 +66,7 @@ steps: | ||||
| - uses: actions/setup-node@v3 | ||||
|   with: | ||||
|     node-version-file: '.nvmrc' | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -51,11 +86,11 @@ jobs: | ||||
|         with: | ||||
|           node-version: '14' | ||||
|           architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default | ||||
|       - run: npm install | ||||
|       - run: npm ci | ||||
|       - run: npm test | ||||
| ``` | ||||
|  | ||||
| ## Caching packages dependencies | ||||
| ## Caching packages data | ||||
| The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions. | ||||
|  | ||||
| **Caching yarn dependencies:** | ||||
| @@ -67,7 +102,7 @@ steps: | ||||
|   with: | ||||
|     node-version: '14' | ||||
|     cache: 'yarn' | ||||
| - run: yarn install | ||||
| - run: yarn install --frozen-lockfile # optional, --immutable | ||||
| - run: yarn test | ||||
| ``` | ||||
|  | ||||
| @@ -82,14 +117,14 @@ steps: | ||||
|  | ||||
| steps: | ||||
| - uses: actions/checkout@v3 | ||||
| - uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2 | ||||
| - uses: pnpm/action-setup@v2 | ||||
|   with: | ||||
|     version: 6.10.0 | ||||
|     version: 6.32.9 | ||||
| - uses: actions/setup-node@v3 | ||||
|   with: | ||||
|     node-version: '14' | ||||
|     cache: 'pnpm' | ||||
| - run: pnpm install | ||||
| - run: pnpm install --frozen-lockfile | ||||
| - run: pnpm test | ||||
| ``` | ||||
|  | ||||
| @@ -102,7 +137,7 @@ steps: | ||||
|     node-version: '14' | ||||
|     cache: 'npm' | ||||
|     cache-dependency-path: '**/package-lock.json' | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -117,7 +152,7 @@ steps: | ||||
|     cache-dependency-path: | | ||||
|       server/app/package-lock.json | ||||
|       frontend/app/package-lock.json | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -152,7 +187,7 @@ jobs: | ||||
|         with: | ||||
|           node-version: ${{ matrix.node_version }} | ||||
|           architecture: ${{ matrix.architecture }} | ||||
|       - run: npm install | ||||
|       - run: npm ci | ||||
|       - run: npm test | ||||
| ``` | ||||
|  | ||||
| @@ -164,7 +199,7 @@ steps: | ||||
|   with: | ||||
|     node-version: '14.x' | ||||
|     registry-url: 'https://registry.npmjs.org' | ||||
| - run: npm install | ||||
| - run: npm ci | ||||
| - run: npm publish | ||||
|   env: | ||||
|     NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||
| @@ -184,7 +219,7 @@ steps: | ||||
|   with: | ||||
|     node-version: '14.x' | ||||
|     registry-url: <registry url> | ||||
| - run: yarn install | ||||
| - run: yarn install --frozen-lockfile | ||||
| - run: yarn publish | ||||
|   env: | ||||
|     NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }} | ||||
| @@ -206,7 +241,7 @@ steps: | ||||
|     registry-url: 'https://registry.npmjs.org' | ||||
| # Skip post-install scripts here, as a malicious | ||||
| # script could steal NODE_AUTH_TOKEN. | ||||
| - run: npm install --ignore-scripts | ||||
| - run: npm ci --ignore-scripts | ||||
|   env: | ||||
|     NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||
| # `npm rebuild` will run all those post-install scripts for us. | ||||
|   | ||||
							
								
								
									
										19
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										19
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -23,7 +23,7 @@ | ||||
|         "@types/jest": "^27.0.2", | ||||
|         "@types/node": "^16.11.25", | ||||
|         "@types/semver": "^6.0.0", | ||||
|         "@zeit/ncc": "^0.21.0", | ||||
|         "@vercel/ncc": "^0.33.4", | ||||
|         "jest": "^27.2.5", | ||||
|         "jest-circus": "^27.2.5", | ||||
|         "prettier": "^1.19.1", | ||||
| @@ -1535,11 +1535,10 @@ | ||||
|       "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", | ||||
|       "dev": true | ||||
|     }, | ||||
|     "node_modules/@zeit/ncc": { | ||||
|       "version": "0.21.0", | ||||
|       "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz", | ||||
|       "integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==", | ||||
|       "deprecated": "@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.", | ||||
|     "node_modules/@vercel/ncc": { | ||||
|       "version": "0.33.4", | ||||
|       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.33.4.tgz", | ||||
|       "integrity": "sha512-ln18hs7dMffelP47tpkaR+V5Tj6coykNyxJrlcmCormPqRQjB/Gv4cu2FfBG+PMzIfdZp2CLDsrrB1NPU22Qhg==", | ||||
|       "dev": true, | ||||
|       "bin": { | ||||
|         "ncc": "dist/ncc/cli.js" | ||||
| @@ -6347,10 +6346,10 @@ | ||||
|       "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", | ||||
|       "dev": true | ||||
|     }, | ||||
|     "@zeit/ncc": { | ||||
|       "version": "0.21.0", | ||||
|       "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz", | ||||
|       "integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==", | ||||
|     "@vercel/ncc": { | ||||
|       "version": "0.33.4", | ||||
|       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.33.4.tgz", | ||||
|       "integrity": "sha512-ln18hs7dMffelP47tpkaR+V5Tj6coykNyxJrlcmCormPqRQjB/Gv4cu2FfBG+PMzIfdZp2CLDsrrB1NPU22Qhg==", | ||||
|       "dev": true | ||||
|     }, | ||||
|     "abab": { | ||||
|   | ||||
| @@ -37,7 +37,7 @@ | ||||
|     "@types/jest": "^27.0.2", | ||||
|     "@types/node": "^16.11.25", | ||||
|     "@types/semver": "^6.0.0", | ||||
|     "@zeit/ncc": "^0.21.0", | ||||
|     "@vercel/ncc": "^0.33.4", | ||||
|     "jest": "^27.2.5", | ||||
|     "jest-circus": "^27.2.5", | ||||
|     "prettier": "^1.19.1", | ||||
|   | ||||
| @@ -37,6 +37,7 @@ export async function getNode( | ||||
| ) { | ||||
|   // Store manifest data to avoid multiple calls | ||||
|   let manifest: INodeRelease[] | undefined; | ||||
|   let nodeVersions: INodeVersion[] | undefined; | ||||
|   let osPlat: string = os.platform(); | ||||
|   let osArch: string = translateArchToDistUrl(arch); | ||||
|  | ||||
| @@ -49,6 +50,12 @@ export async function getNode( | ||||
|     versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest); | ||||
|   } | ||||
|  | ||||
|   if (isLatestSyntax(versionSpec)) { | ||||
|     nodeVersions = await getVersionsFromDist(); | ||||
|     versionSpec = await queryDistForMatch(versionSpec, arch, nodeVersions); | ||||
|     core.info(`getting latest node version...`); | ||||
|   } | ||||
|  | ||||
|   if (checkLatest) { | ||||
|     core.info('Attempt to resolve the latest version from manifest...'); | ||||
|     const resolvedVersion = await resolveVersionFromManifest( | ||||
| @@ -119,7 +126,7 @@ export async function getNode( | ||||
|     // Download from nodejs.org | ||||
|     // | ||||
|     if (!downloadPath) { | ||||
|       info = await getInfoFromDist(versionSpec, arch); | ||||
|       info = await getInfoFromDist(versionSpec, arch, nodeVersions); | ||||
|       if (!info) { | ||||
|         throw new Error( | ||||
|           `Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.` | ||||
| @@ -216,13 +223,21 @@ function resolveLtsAliasFromManifest( | ||||
|  | ||||
|   core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`); | ||||
|  | ||||
|   // Supported formats are `lts/<alias>` and `lts/*`. Where asterisk means highest possible LTS. | ||||
|   // Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest. | ||||
|   const n = Number(alias); | ||||
|   const aliases = Object.fromEntries( | ||||
|     manifest | ||||
|       .filter(x => x.lts && x.stable === stable) | ||||
|       .map(x => [x.lts!.toLowerCase(), x]) | ||||
|       .reverse() | ||||
|   ); | ||||
|   const numbered = Object.values(aliases); | ||||
|   const release = | ||||
|     alias === '*' | ||||
|       ? manifest.find(x => !!x.lts && x.stable === stable) | ||||
|       : manifest.find( | ||||
|           x => x.lts?.toLowerCase() === alias && x.stable === stable | ||||
|         ); | ||||
|       ? numbered[numbered.length - 1] | ||||
|       : n < 0 | ||||
|       ? numbered[numbered.length - 1 + n] | ||||
|       : aliases[alias]; | ||||
|  | ||||
|   if (!release) { | ||||
|     throw new Error( | ||||
| @@ -265,14 +280,18 @@ async function getInfoFromManifest( | ||||
|  | ||||
| async function getInfoFromDist( | ||||
|   versionSpec: string, | ||||
|   arch: string = os.arch() | ||||
|   arch: string = os.arch(), | ||||
|   nodeVersions?: INodeVersion[] | ||||
| ): Promise<INodeVersionInfo | null> { | ||||
|   let osPlat: string = os.platform(); | ||||
|   let osArch: string = translateArchToDistUrl(arch); | ||||
|  | ||||
|   let version: string; | ||||
|   let version: string = await queryDistForMatch( | ||||
|     versionSpec, | ||||
|     arch, | ||||
|     nodeVersions | ||||
|   ); | ||||
|  | ||||
|   version = await queryDistForMatch(versionSpec, arch); | ||||
|   if (!version) { | ||||
|     return null; | ||||
|   } | ||||
| @@ -349,7 +368,8 @@ function evaluateVersions(versions: string[], versionSpec: string): string { | ||||
|  | ||||
| async function queryDistForMatch( | ||||
|   versionSpec: string, | ||||
|   arch: string = os.arch() | ||||
|   arch: string = os.arch(), | ||||
|   nodeVersions?: INodeVersion[] | ||||
| ): Promise<string> { | ||||
|   let osPlat: string = os.platform(); | ||||
|   let osArch: string = translateArchToDistUrl(arch); | ||||
| @@ -370,8 +390,17 @@ async function queryDistForMatch( | ||||
|       throw new Error(`Unexpected OS '${osPlat}'`); | ||||
|   } | ||||
|  | ||||
|   if (!nodeVersions) { | ||||
|     core.debug('No dist manifest cached'); | ||||
|     nodeVersions = await getVersionsFromDist(); | ||||
|   } | ||||
|  | ||||
|   let versions: string[] = []; | ||||
|   let nodeVersions = await getVersionsFromDist(); | ||||
|  | ||||
|   if (isLatestSyntax(versionSpec)) { | ||||
|     core.info(`getting latest node version...`); | ||||
|     return nodeVersions[0].version; | ||||
|   } | ||||
|  | ||||
|   nodeVersions.forEach((nodeVersion: INodeVersion) => { | ||||
|     // ensure this version supports your os and platform | ||||
| @@ -473,3 +502,7 @@ export function parseNodeVersionFile(contents: string): string { | ||||
|   } | ||||
|   return nodeVersion; | ||||
| } | ||||
|  | ||||
| function isLatestSyntax(versionSpec): boolean { | ||||
|   return ['current', 'latest', 'node'].includes(versionSpec); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user