electron-mksnapshot 22.0.0 → 23.0.0

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.
@@ -1,73 +1,114 @@
1
- # Javascript Node CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4
- #
5
- version: 2
6
- jobs:
7
- install-test-linux:
8
- docker:
9
- # specify the version you desire here
10
- - image: circleci/node:14-browsers
1
+ version: 2.1
11
2
 
12
- # Specify service dependencies here if necessary
13
- # CircleCI maintains a library of pre-built images
14
- # documented at https://circleci.com/docs/2.0/circleci-images/
15
- # - image: circleci/mongo:3.4.4
16
-
17
- working_directory: ~/repo
3
+ orbs:
4
+ node: circleci/node@5.1.0
5
+ win: circleci/windows@5.0.0
18
6
 
7
+ commands:
8
+ install:
19
9
  steps:
10
+ - node/install:
11
+ node-version: "16.19.0"
12
+ - run: nvm use 16.19.0
20
13
  - checkout
21
-
22
- # Download and cache dependencies
23
14
  - restore_cache:
24
15
  keys:
25
- - v1-dependencies-{{ checksum "package.json" }}
26
- # fallback to using the latest cache if no exact match is found
27
- - v1-dependencies-
28
-
29
- - run: npm install
30
-
16
+ - v1-dependencies-{{ arch }}-{{ checksum "package-lock.json" }}
17
+ - v1-dependencies-{{ arch }}
18
+ - when:
19
+ condition: << pipeline.git.tag >>
20
+ steps:
21
+ - run:
22
+ name: Update Version
23
+ command: node script/update-version.js << pipeline.git.tag >>
24
+ - run: npm install
25
+ - unless:
26
+ condition: << pipeline.git.tag >>
27
+ steps:
28
+ - run:
29
+ command: npm install
30
+ environment:
31
+ ELECTRON_MKSNAPSHOT_STABLE_FALLBACK: 1
31
32
  - save_cache:
32
33
  paths:
33
34
  - node_modules
34
- key: v1-dependencies-{{ checksum "package.json" }}
35
-
36
- # run tests!
35
+ key: v1-dependencies-{{ arch }}-{{ checksum "package-lock.json" }}
36
+ test:
37
+ steps:
37
38
  - run: node --version
38
39
  - run: npm --version
39
40
  - run: npm test
40
41
 
41
- install-test-osx:
42
+ jobs:
43
+ test-linux:
44
+ docker:
45
+ - image: cimg/base:stable
46
+ steps:
47
+ - install
48
+ - test
49
+ test-mac:
42
50
  macos:
43
- xcode: "13.3.0"
51
+ xcode: "13.3.0"
52
+ steps:
53
+ - install
54
+ - test
55
+ test-windows:
56
+ executor:
57
+ name: win/default
58
+ shell: bash.exe
59
+ steps:
60
+ - install
61
+ - test
62
+ release:
63
+ docker:
64
+ - image: cimg/node:18.14
44
65
  steps:
45
66
  - checkout
46
-
47
- # Download and cache dependencies
48
- - restore_cache:
49
- keys:
50
- - v1-mac-dependencies-{{ checksum "package.json" }}
51
- # fallback to using the latest cache if no exact match is found
52
- - v1-mac-dependencies-
53
-
54
- - run: npm install
55
-
56
- - save_cache:
57
- paths:
58
- - node_modules
59
- key: v1-mac-dependencies-{{ checksum "package.json" }}
60
-
61
- # run tests!
62
- - run: node --version
63
- - run: npm --version
64
- - run: npm test
67
+ - run:
68
+ name: Update Version
69
+ command: node script/update-version.js << pipeline.git.tag >>
70
+ - run:
71
+ name: Install Dependencies
72
+ command: npm ci
73
+ - run:
74
+ name: Obtain Publishing Credentials
75
+ command: npx @continuous-auth/circleci-oidc-github-auth@1.0.4
76
+ - run:
77
+ name: Confirm Version Updated
78
+ command: node -e "if (require('./package.json').version === '0.0.0-development') process.exit(1)"
79
+ - run:
80
+ name: Set NPM Credentials
81
+ command: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc
82
+ - run:
83
+ name: Check NPM Credentials
84
+ command: npm whoami
85
+ - run:
86
+ name: CFA Publish
87
+ command: node script/publish.js
65
88
 
66
89
  workflows:
67
- version: 2
68
- test-linux:
69
- jobs:
70
- - install-test-linux
71
- test-osx:
90
+ test_and_release:
72
91
  jobs:
73
- - install-test-osx
92
+ - test-linux:
93
+ filters:
94
+ tags:
95
+ only: /.*/
96
+ - test-mac:
97
+ filters:
98
+ tags:
99
+ only: /.*/
100
+ - test-windows:
101
+ filters:
102
+ tags:
103
+ only: /.*/
104
+ - release:
105
+ requires:
106
+ - test-linux
107
+ - test-mac
108
+ - test-windows
109
+ filters:
110
+ tags:
111
+ only: /^v.*/
112
+ branches:
113
+ ignore: /.*/
114
+ context: cfa-release
@@ -11,13 +11,14 @@ env:
11
11
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12
12
 
13
13
  jobs:
14
- run_tests:
15
- strategy:
16
- matrix:
17
- os: [ubuntu-latest, macos-latest]
18
- runs-on: ${{ matrix.os }}
14
+ smoke_test:
15
+ runs-on: ubuntu-latest
19
16
  steps:
20
- - uses: actions/checkout@v3
17
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag: v3.3.0
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # tag: v3.6.0
20
+ with:
21
+ node-version: "16.19.0"
21
22
  - name: Update Version
22
23
  run: node script/update-version.js ${{ github.event.inputs.version }}
23
24
  - name: Install Dependencies
@@ -26,37 +27,15 @@ jobs:
26
27
  run: npm test
27
28
  create_new_version:
28
29
  runs-on: ubuntu-latest
29
- needs: run_tests
30
+ needs: smoke_test
30
31
  steps:
31
- - uses: actions/checkout@v3
32
- - name: Use Node.js v16
33
- uses: actions/setup-node@v3
34
- with:
35
- node-version: 16.x
36
- registry-url: 'https://registry.npmjs.org'
37
- - name: Check npm credentials
38
- run: npm whoami
39
- env:
40
- NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
41
- - name: Set Git Credentials
42
- run: |
43
- git config user.name electron-bot
44
- git config user.email electron@github.com
45
- - name: Update Version
46
- run: node script/update-version.js ${{ github.event.inputs.version }}
47
- - name: Push Update Commit
48
- run: |
49
- git add .
50
- git commit -m "chore: update version to ${{ github.event.inputs.version }}"
51
- git push origin main
32
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag: v3.3.0
33
+ # Tag here, the CircleCI workflow will trigger on the new tag and do the CFA publish
52
34
  - name: Push New Tag
53
35
  run: |
54
36
  git tag ${{ github.event.inputs.version }}
55
37
  git push origin ${{ github.event.inputs.version }}
38
+ # TODO - This creates a draft release at the moment
56
39
  - name: Create Release
57
40
  run: |
58
- gh release create ${{ github.event.inputs.version }} -t ${{ github.event.inputs.version }}
59
- - name: Publish to npm
60
- run: npm publish
61
- env:
62
- NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
41
+ gh release create ${{ github.event.inputs.version }} -t ${{ github.event.inputs.version }} -d
@@ -7,14 +7,20 @@ on:
7
7
  - edited
8
8
  - synchronize
9
9
 
10
+ permissions:
11
+ contents: read
12
+
10
13
  jobs:
11
14
  main:
15
+ permissions:
16
+ pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
17
+ statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
12
18
  name: Validate PR Title
13
19
  runs-on: ubuntu-latest
14
20
  steps:
15
21
  - name: semantic-pull-request
16
- uses: amannn/action-semantic-pull-request@v4
22
+ uses: amannn/action-semantic-pull-request@01d5fd8a8ebb9aafe902c40c53f0f4744f7381eb # tag: v5
17
23
  env:
18
24
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
25
  with:
20
- validateSingleCommit: true
26
+ validateSingleCommit: false
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Contributors to the Electron project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # Electron mksnapshot
2
2
 
3
- [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/ugparq4awqbf4fq5/branch/main?svg=true)](https://ci.appveyor.com/project/electron-bot/mksnapshot/branch/main)
4
- [![Linux and Mac Build Status](https://circleci.com/gh/electron/mksnapshot/tree/main.svg?style=shield)](https://circleci.com/gh/electron/mksnapshot/tree/main)
3
+ [![CircleCI Status](https://circleci.com/gh/electron/mksnapshot/tree/main.svg?style=shield)](https://circleci.com/gh/electron/mksnapshot/tree/main)
4
+ [![npm:](https://img.shields.io/npm/v/electron-mksnapshot.svg)](https://www.npmjs.com/package/electron-mksnapshot)
5
5
  <br>
6
6
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
7
7
  [![license:mit](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)
8
8
  <br>
9
- [![npm:](https://img.shields.io/npm/v/electron-mksnapshot.svg)](https://www.npmjs.com/package/electron-mksnapshot)
10
9
  [![dependencies:?](https://img.shields.io/npm/dm/electron-mksnapshot.svg)](https://www.npmjs.com/package/electron-mksnapshot)
11
10
 
12
11
  Simple node module to download the `mksnapshot` binaries compatible with
@@ -5,15 +5,31 @@ const extractZip = require('extract-zip')
5
5
  const versionToDownload = require('./package').version
6
6
  let archToDownload = process.env.npm_config_arch
7
7
 
8
- if (process.arch.indexOf('arm') === 0 && process.platform !== 'darwin') {
9
- console.log(`WARNING: mksnapshot does not run on ${process.arch}. Download
10
- https://github.com/electron/electron/releases/download/v${versionToDownload}/mksnapshot-v${versionToDownload}-${process.platform}-${process.arch}-x64.zip
11
- on a x64 ${process.platform} OS to generate ${archToDownload} snapshots.`)
12
- process.exit(1)
8
+ // Refs https://github.com/electron/fiddle-core/blob/1ee2d2737f23fd1012917a249a9444b6db89f1d8/src/versions.ts#L47-L57
9
+ function compareVersions (a, b) {
10
+ const l = a.compareMain(b)
11
+ if (l) return l
12
+ // Electron's approach is nightly -> other prerelease tags -> stable,
13
+ // so force `nightly` to sort before other prerelease tags.
14
+ const [prea] = a.prerelease
15
+ const [preb] = b.prerelease
16
+ if (prea === 'nightly' && preb !== 'nightly') return -1
17
+ if (prea !== 'nightly' && preb === 'nightly') return 1
18
+ return a.comparePre(b)
13
19
  }
14
20
 
15
- if (archToDownload && archToDownload.indexOf('arm') === 0 && process.platform !== 'darwin') {
16
- archToDownload += '-x64'
21
+ // Refs https://github.com/electron/fiddle-core/blob/1ee2d2737f23fd1012917a249a9444b6db89f1d8/src/versions.ts#L152-L160
22
+ function getLatestStable (releases) {
23
+ const { parse: semverParse } = require('semver')
24
+ const semvers = releases.map(({ version }) => semverParse(version)).filter((sem) => Boolean(sem))
25
+ semvers.sort((a, b) => compareVersions(a, b))
26
+ let stable
27
+ for (const ver of semvers.values()) {
28
+ if (ver.prerelease.length === 0) {
29
+ stable = ver
30
+ }
31
+ }
32
+ return stable
17
33
  }
18
34
 
19
35
  function download (version) {
@@ -28,6 +44,29 @@ function download (version) {
28
44
  }
29
45
 
30
46
  async function attemptDownload (version) {
47
+ // Fall back to latest stable if there is not a stamped version, for tests
48
+ if (version === '0.0.0-development') {
49
+ if (!process.env.ELECTRON_MKSNAPSHOT_STABLE_FALLBACK) {
50
+ console.log('WARNING: mksnapshot in development needs the environment variable ELECTRON_MKSNAPSHOT_STABLE_FALLBACK set')
51
+ process.exit(1)
52
+ }
53
+
54
+ const fetch = require('node-fetch')
55
+ const releases = await fetch('https://releases.electronjs.org/releases.json').then(response => response.json())
56
+ version = getLatestStable(releases).version
57
+ }
58
+
59
+ if (process.arch.indexOf('arm') === 0 && process.platform !== 'darwin') {
60
+ console.log(`WARNING: mksnapshot does not run on ${process.arch}. Download
61
+ https://github.com/electron/electron/releases/download/v${version}/mksnapshot-v${version}-${process.platform}-${process.arch}-x64.zip
62
+ on a x64 ${process.platform} OS to generate ${archToDownload} snapshots.`)
63
+ process.exit(1)
64
+ }
65
+
66
+ if (archToDownload && archToDownload.indexOf('arm') === 0 && process.platform !== 'darwin') {
67
+ archToDownload += '-x64'
68
+ }
69
+
31
70
  try {
32
71
  const targetFolder = path.join(__dirname, 'bin')
33
72
  const zipPath = await download(version)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-mksnapshot",
3
- "version": "22.0.0",
3
+ "version": "23.0.0",
4
4
  "description": "Electron version of the mksnapshot binary",
5
5
  "repository": "https://github.com/electron/mksnapshot",
6
6
  "bin": {
@@ -19,7 +19,10 @@
19
19
  "temp": "^0.8.3"
20
20
  },
21
21
  "devDependencies": {
22
+ "@continuous-auth/client": "^2.2.2",
22
23
  "mocha": "^10.1.0",
24
+ "node-fetch": "^2.6.9",
25
+ "semver": "^7.3.8",
23
26
  "standard": "^14.3.1"
24
27
  },
25
28
  "standard": {
@@ -30,4 +33,4 @@
30
33
  "engines": {
31
34
  "node": ">=10.5.0"
32
35
  }
33
- }
36
+ }
@@ -0,0 +1,11 @@
1
+ // Publish the package in the CWD with an OTP code from CFA
2
+ const { getOtp } = require('@continuous-auth/client')
3
+ const { spawnSync } = require('child_process')
4
+
5
+ async function publish () {
6
+ const { status, stdout } = spawnSync('npm', ['publish', '--otp', await getOtp()])
7
+ if (status !== 0) console.log(stdout)
8
+ process.exit(status)
9
+ }
10
+
11
+ publish()
@@ -10,8 +10,8 @@ const normalizeVersion = (version = '') => {
10
10
  async function updateVersion () {
11
11
  const version = normalizeVersion(process.argv[2])
12
12
  if (!versionFormat.test(version)) {
13
- console.error(`Invalid version ${version}`)
14
- process.exit(1)
13
+ console.error(`Unsupported version ${version} - only major, minor, and patch releases are currently supported`)
14
+ return
15
15
  }
16
16
 
17
17
  const PJ_PATH = path.join(__dirname, '..', 'package.json')