create-polyfill-service-url 2.2.5 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -22,19 +22,42 @@ A Node.js command-line application for analysing your JavaScript file and genera
22
22
 
23
23
 
24
24
  ## Usage
25
-
25
+ ### CLI
26
26
  This project requires [Node.js] 10.x and [npm]. You can run it with:
27
27
 
28
28
  ```bash
29
- > npx create-polyfill-service-url analyse --file bundle.js
29
+ > npx create-polyfill-service-url analyse --file bundle.js [--cwd "/custom/pwd" --omit "Array.prototype.includes" --hostname "polyfill.io"]
30
30
  ```
31
-
32
31
  You can pass multiple files as argument if you split your bundle files:
33
-
34
32
  ```bash
35
33
  npx create-polyfill-service-url analyse --file app.js vendor.js
36
34
  ```
37
35
 
36
+ | Option | Description | Default |
37
+ |-------------------------------|-------------------------------------------------------------------------------------------------------------|-----------------|
38
+ | --file | The path to the JavaScript file(s) to analyse | |
39
+ | --cwd | The current working directory | `process.cwd()` |
40
+ | --omit | A list of features to omit. Example: `Array.prototype.map` | |
41
+ | --hostname | The hostname of the polyfill service to use. | `polyfill.io` |
42
+ | --use-compute-at-edge-backend | Defines the compute-at-edge-backend usage policy: `yes` or `no`. If empty the server will decide. | |
43
+ | --flags | Configuration settings for every polyfill being requested. Possible values are `always` and `gated` or both | |
44
+ | --unknown | Defines the policy for unsupported browsers: `polyfill` or `ignore` | `polyfill` |
45
+
46
+ ### JS API
47
+ ```js
48
+ const analyze = require('create-polyfill-service-url');
49
+
50
+ const result = await analyze({
51
+ file: ['bundle.js'],
52
+ cwd: '/foo/bar', // Defaults to process.cwd()
53
+ omit: ['Array.prototype.includes'], // Defaults to []
54
+ hostname: 'example.com', // Defaults to 'polyfill.io'
55
+ unknown: 'polyfill', // Defaults to null. Accepts 'polyfill' or 'ignore'
56
+ useComputeAtEdgeBackend: 'yes', // Defaults to null. Accepts 'yes' or 'no'
57
+ flags: 'gated', // Defaults to null. Accepts 'always', 'gated' or both ['always', 'gated']
58
+ });
59
+ ```
60
+
38
61
  ## Contributing
39
62
 
40
63
  This module has a full suite of unit tests, and is verified with ESLint. You can use the following commands to check your code before opening a pull request:
package/index.js CHANGED
@@ -14,97 +14,34 @@ require('yargs')
14
14
  describe: 'The file that should be analysed',
15
15
  demandOption: true,
16
16
  },
17
+ omit: {
18
+ array: true,
19
+ string: true,
20
+ describe: 'The list of features to omit',
21
+ },
22
+ cwd: {
23
+ string: true,
24
+ describe: 'The current working directory. Defaults to process.cwd()',
25
+ },
26
+ hostname: {
27
+ string: true,
28
+ describe: 'The hostname to use for the generated URL. Defaults to polyfill.io',
29
+ },
30
+ useComputeAtEdgeBackend: {
31
+ string: true,
32
+ describe: 'Defines the compute-at-edge-backend usage policy: `yes` or `no`. If empty the server will decide.',
33
+ },
34
+ flags: {
35
+ array: true,
36
+ string: true,
37
+ describe: 'Configuration settings for every polyfill being requested. Possible values are `always` and `gated` or both',
38
+ },
39
+ unknown: {
40
+ string: true,
41
+ describe: 'Defines the policy for unsupported browsers: `polyfill` or `ignore`. Defaults to `polyfill`',
42
+ },
17
43
  },
18
- async function parseFile(argv) {
19
- const browserslist = require('browserslist');
20
- const browsersListConfig = browserslist.loadConfig({
21
- path: process.cwd(),
22
- });
23
- let browsers = [];
24
- if (browsersListConfig) {
25
- browsers = browserslist(browsersListConfig);
26
- }
27
-
28
- const generatePolyfillURL = require('./src/index.js');
29
- const path = require('path');
30
- const babel = require('@babel/core');
31
- const plugin = require('@financial-times/js-features-analyser/src/index.js');
32
- const fs = require('fs');
33
- const os = require('os');
34
- const promisify = require('util').promisify;
35
- const readFile = promisify(fs.readFile);
36
- const mkdtemp = promisify(fs.mkdtemp);
37
-
38
- const promiseList = argv.file.map(async filename => {
39
- const file = path.join(process.cwd(), filename);
40
- const fileContents = await readFile(file, 'utf-8');
41
- const tempFolder = await mkdtemp(
42
- path.join(os.tmpdir(), 'js-features-analyser')
43
- );
44
- const outputDestination = path.join(tempFolder, 'features.json');
45
-
46
- try {
47
- babel.transformSync(fileContents, {
48
- plugins: [
49
- [
50
- plugin,
51
- {
52
- outputDestination,
53
- },
54
- ],
55
- ],
56
- filename: file,
57
- ast: false,
58
- code: false,
59
- });
60
-
61
- return JSON.parse(fs.readFileSync(outputDestination, 'utf-8'));
62
- } catch (error) {
63
- if (error instanceof SyntaxError) {
64
- console.error(
65
- 'Failed to parse the JavaScript from xxx because it has a syntax error.'
66
- );
67
- delete error.stack;
68
- delete error.code;
69
- delete error.pos;
70
- delete error.loc;
71
- const result = /: (?<errorType>[\w ]+) \((?<position>\d+:\d+)\)/.exec(
72
- error.message
73
- );
74
- console.error(result.groups.errorType);
75
- error.message = error.message.replace(
76
- ` ${result.groups.errorType} `,
77
- ''
78
- );
79
- error.message = error.message.replace(
80
- `(${result.groups.position})`,
81
- result.groups.position
82
- );
83
- console.error(error.message);
84
- } else {
85
- console.error(
86
- 'Failed to parse the JavaScript from xxx because an error occured:'
87
- );
88
- console.error(error);
89
- }
90
- }
91
- });
92
-
93
- const resultList = await Promise.all(promiseList);
94
- const featureList = resultList.reduce(
95
- (carry, item) => [...carry, ...item],
96
- []
97
- );
98
- const uniqueFeatureList = [...new Set(featureList)];
99
-
100
- const result = await generatePolyfillURL(uniqueFeatureList, browsers);
101
-
102
- if (result.type === generatePolyfillURL.TYPE_URL) {
103
- console.log(result.message);
104
- } else if (result.type === generatePolyfillURL.TYPE_NOTHING) {
105
- console.error(result.message);
106
- }
107
- }
44
+ require('./src/analyse')
108
45
  )
109
46
  .help()
110
47
  .strict().argv;
package/package.json CHANGED
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "name": "create-polyfill-service-url",
3
3
  "bin": "./index.js",
4
+ "main": "./src/analyse.js",
5
+ "files": [
6
+ "index.js",
7
+ "src",
8
+ "README.md",
9
+ "CHANGELOG.md",
10
+ "LICENSE.md"
11
+ ],
4
12
  "scripts": {
5
13
  "fix": "eslint . --fix",
6
14
  "lint": "eslint .",
@@ -9,19 +17,20 @@
9
17
  "prepare": "npm run snyk-protect"
10
18
  },
11
19
  "devDependencies": {
12
- "eslint": "^7.0.0",
13
- "jest": "^26.0.0"
20
+ "eslint": "^8.40.0",
21
+ "jest": "^29.5.0",
22
+ "tinysh": "^1.0.0"
14
23
  },
15
- "version": "2.2.5",
24
+ "version": "2.3.0",
16
25
  "dependencies": {
17
- "@babel/core": "^7.5.5",
18
- "@financial-times/js-features-analyser": "0.0.4",
19
- "browserslist": "^4.8.3",
20
- "execa": "^4.0.0",
21
- "polyfill-library": "^3.37.0",
22
- "semver": "^7.1.1",
23
- "yargs": "^15.1.0",
24
- "snyk": "^1.425.4"
26
+ "@babel/core": "^7.21.8",
27
+ "@financial-times/js-features-analyser": "^0.4.3",
28
+ "browserslist": "^4.21.5",
29
+ "execa": "^7.1.1",
30
+ "polyfill-library": "^4.7.0",
31
+ "semver": "^7.5.0",
32
+ "yargs": "^17.7.2",
33
+ "snyk": "^1.1153.0"
25
34
  },
26
35
  "repository": {
27
36
  "type": "git",
package/src/analyse.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ module.exports = async function parseFile(argv) {
4
+ const {
5
+ cwd = process.cwd(),
6
+ hostname,
7
+ flags,
8
+ useComputeAtEdgeBackend,
9
+ unknown,
10
+ } = argv;
11
+ const omitList = argv.omit || [];
12
+ const browserslist = require('browserslist');
13
+ const browsersListConfig = browserslist.loadConfig({
14
+ path: cwd,
15
+ });
16
+ let browsers = [];
17
+ if (browsersListConfig) {
18
+ browsers = browserslist(browsersListConfig);
19
+ }
20
+
21
+ const generatePolyfillURL = require('./index.js');
22
+ const path = require('path');
23
+ const babel = require('@babel/core');
24
+ const plugin = require('@financial-times/js-features-analyser/src/index.js');
25
+ const fs = require('fs');
26
+ const os = require('os');
27
+ const promisify = require('util').promisify;
28
+ const readFile = promisify(fs.readFile);
29
+ const mkdtemp = promisify(fs.mkdtemp);
30
+
31
+ const promiseList = argv.file.map(async filename => {
32
+ const file = path.join(cwd, filename);
33
+ const fileContents = await readFile(file, 'utf-8');
34
+ const tempFolder = await mkdtemp(
35
+ path.join(os.tmpdir(), 'js-features-analyser')
36
+ );
37
+ const outputDestination = path.join(tempFolder, 'features.json');
38
+
39
+ try {
40
+ babel.transformSync(fileContents, {
41
+ plugins: [
42
+ [
43
+ plugin,
44
+ {
45
+ outputDestination,
46
+ },
47
+ ],
48
+ ],
49
+ filename: file,
50
+ ast: false,
51
+ code: false,
52
+ });
53
+
54
+ return JSON.parse(fs.readFileSync(outputDestination, 'utf-8'));
55
+ } catch (error) {
56
+ if (error instanceof SyntaxError) {
57
+ console.error(
58
+ 'Failed to parse the JavaScript from xxx because it has a syntax error.'
59
+ );
60
+ delete error.stack;
61
+ delete error.code;
62
+ delete error.pos;
63
+ delete error.loc;
64
+ const result = /: (?<errorType>[\w ]+) \((?<position>\d+:\d+)\)/.exec(
65
+ error.message
66
+ );
67
+ console.error(result.groups.errorType);
68
+ error.message = error.message.replace(
69
+ ` ${result.groups.errorType} `,
70
+ ''
71
+ );
72
+ error.message = error.message.replace(
73
+ `(${result.groups.position})`,
74
+ result.groups.position
75
+ );
76
+ console.error(error.message);
77
+ } else {
78
+ console.error(
79
+ 'Failed to parse the JavaScript from xxx because an error occured:'
80
+ );
81
+ console.error(error);
82
+ }
83
+ }
84
+ });
85
+
86
+ const resultList = await Promise.all(promiseList);
87
+ const featureList = resultList.reduce(
88
+ (carry, item) => [...carry, ...item],
89
+ []
90
+ );
91
+
92
+ const clonedFeatureList = [...featureList];
93
+
94
+ for (const feature of clonedFeatureList) {
95
+ const parts = feature.split('.');
96
+ if (parts.length >= 2 && parts[1] === 'prototype') {
97
+ if (parts[0] === 'Document') {
98
+ parts[0] = parts[0].toLowerCase();
99
+ }
100
+ else if (parts[0] === 'element') {
101
+ parts[0] = parts[0].toUpperCase();
102
+ }
103
+ parts[0] = parts[0].toLowerCase();
104
+ featureList.push(parts[0] + '.' + parts.slice(2).join('.'))
105
+ }
106
+ }
107
+
108
+ const filteredFeatureList = featureList.filter((feat) => !omitList.includes(feat))
109
+ const uniqueFeatureList = [...new Set(filteredFeatureList)];
110
+
111
+ const result = await generatePolyfillURL(uniqueFeatureList, browsers, hostname, flags, useComputeAtEdgeBackend, unknown);
112
+
113
+ if (result.type === generatePolyfillURL.TYPE_URL) {
114
+ console.log(result.message);
115
+ } else if (result.type === generatePolyfillURL.TYPE_NOTHING) {
116
+ console.error(result.message);
117
+ }
118
+
119
+ return result;
120
+ };
package/src/index.js CHANGED
@@ -62,11 +62,18 @@ function normaliseBrowsers(browsers) {
62
62
  a => a.split(" ")
63
63
  );
64
64
  }
65
- async function generatePolyfillURL(features = [], supportedBrowsers = []) {
65
+ async function generatePolyfillURL(
66
+ features = [],
67
+ supportedBrowsers = [],
68
+ hostname = "polyfill.io",
69
+ flags = null,
70
+ useComputeAtEdgeBackend = null,
71
+ unknown = null
72
+ ) {
66
73
  if (supportedBrowsers) {
67
74
  supportedBrowsers = normaliseBrowsers(supportedBrowsers);
68
75
  }
69
- const polyfillUrl = "https://polyfill.io/v3/polyfill.min.js";
76
+ const polyfillUrl = new URL('/v3/polyfill.min.js', 'https://' + hostname);
70
77
  const aliases = await polyfillLibrary.listAliases();
71
78
  const polyfills = await polyfillLibrary.listAllPolyfills();
72
79
  const featuresInPolyfillLibrary = new Set();
@@ -156,12 +163,26 @@ async function generatePolyfillURL(features = [], supportedBrowsers = []) {
156
163
  type: TYPE_NOTHING,
157
164
  message: "You do not need to use polyfill.io as all your supported browsers support all the features your website currently uses."
158
165
  };
159
- } else {
160
- return {
161
- type: TYPE_URL,
162
- message: `${polyfillUrl}?features=${sortedFeatures.join(",")}`
163
- }
164
166
  }
167
+
168
+ polyfillUrl.searchParams.set("features", sortedFeatures.join(","));
169
+
170
+ if (flags) {
171
+ polyfillUrl.searchParams.set("flags", Array.isArray(flags) ? flags.join(",") : flags);
172
+ }
173
+
174
+ if (useComputeAtEdgeBackend) {
175
+ polyfillUrl.searchParams.set("use-compute-at-edge-backend", useComputeAtEdgeBackend);
176
+ }
177
+
178
+ if (unknown) {
179
+ polyfillUrl.searchParams.set("unknown", unknown);
180
+ }
181
+
182
+ return {
183
+ type: TYPE_URL,
184
+ message: polyfillUrl.toString().replace(/%2C/g, ",")
185
+ };
165
186
  }
166
187
 
167
188
  module.exports = generatePolyfillURL;
package/.eslintrc.js DELETED
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- "env": {
3
- "commonjs": true,
4
- "es6": true,
5
- "node": true
6
- },
7
- "extends": "eslint:recommended",
8
- "globals": {
9
- "Atomics": "readonly",
10
- "SharedArrayBuffer": "readonly"
11
- },
12
- "parserOptions": {
13
- "ecmaVersion": 2018
14
- },
15
- "rules": {
16
- }
17
- };
@@ -1,7 +0,0 @@
1
- # The Origami Core team is the default owner of all Origami-supported repositories.
2
- # This file adds the owner as a reviewer for all pull requests made to this repository.
3
- # It references owners by source order - the last matching pattern takes the most precedence.
4
-
5
- # If you would like to be added as an owner, please get in touch with the Origami team at origami.support@ft.com or #origami-support on Slack
6
-
7
- * @Financial-Times/origami-core
@@ -1,37 +0,0 @@
1
- ---
2
- title: Issue: [type] [short description]
3
- ---
4
- <!-- [type]: What is this issue for? A bug report? A feature request? -->
5
-
6
- <!--
7
- Please make sure you've checked that your issue hasn't already been raised within this repository.
8
-
9
- If you need help with submitting an issue, please get in touch with the Origami Team at origami.support@ft.com or #origami-support on Slack.
10
- -->
11
- ## What
12
- <!-- A clear description of what the problem or feature request is -->
13
-
14
- ## Details
15
- <!--
16
- If it is a bug:
17
- - describe what the expected behaviour is, and what is actually happening
18
- - add steps on how to reproduce it
19
- - describe the environment you are having this problem in
20
- - Browser + version (e.g. Chrome 70)
21
- - Device (e.g. iPhone X, Desktop)
22
- - provide screenshots to illustrate your problem
23
-
24
- If it is a feature request:
25
- - explain what prompted this request — e.g. is it something that you regularly make a workaround for?
26
- - describe what the new feature would do and how it would be used
27
- - explain what alternatives you have explored / considered
28
- - where possible, attach designs for the style of the new feature
29
- -->
30
-
31
- <!--
32
- ## Additional information
33
- For either type of issue:
34
- - please add any other comments or details you might have
35
- - if you've had a conversation about this with someone, please reference that person in this issue
36
- - if there is a similar or related issue, please link to it
37
- -->
@@ -1,21 +0,0 @@
1
- version: 2
2
- updates:
3
- # Maintain dependencies for npm
4
- - package-ecosystem: "npm"
5
- open-pull-requests-limit: 1
6
- directory: "/"
7
- schedule:
8
- interval: "daily"
9
- allow:
10
- - dependency-type: "development"
11
- labels:
12
- - "dependencies"
13
- ignore:
14
- - dependency-name: "snyk"
15
- # Maintain dependencies for GitHub Actions
16
- - package-ecosystem: "github-actions"
17
- directory: "/"
18
- schedule:
19
- interval: "daily"
20
- labels:
21
- - "dependencies"
@@ -1,16 +0,0 @@
1
- name: Add new issues and pull requests to Origami Project Board
2
- on:
3
- - issues
4
- - pull_request_target
5
- - pull_request
6
-
7
- jobs:
8
- origami_project_board_job:
9
- runs-on: ubuntu-latest
10
- name: Add new issue or pull request to Origami Project Board
11
- steps:
12
- - name: Add new issue or pull request to Origami Project Board
13
- id: origami-project-board
14
- uses: Financial-Times/origami-project-board-action@v1
15
- with:
16
- origami-fox-access-token: ${{ secrets.ORIGAMI_FOX_ACCESS_TOKEN }}
@@ -1,14 +0,0 @@
1
- name: Apply Origami labels
2
- on:
3
- - issues
4
- - pull_request_target
5
- - pull_request
6
- jobs:
7
- apply-labels:
8
- runs-on: ubuntu-latest
9
- name: Apply Origami labels to new issues and pull requests.
10
- steps:
11
- - uses: actions/checkout@v2
12
- - uses: Financial-Times/origami-apply-labels@v1
13
- with:
14
- github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -1,12 +0,0 @@
1
- name: Auto Approve Dependabot PRs
2
-
3
- on: pull_request
4
-
5
- jobs:
6
- auto-approve:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: hmarr/auto-approve-action@v2.0.0
10
- if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
11
- with:
12
- github-token: "${{ secrets.ORIGAMI_FOX_ACCESS_TOKEN }}"
@@ -1,22 +0,0 @@
1
- on:
2
- pull_request:
3
- types: [closed] # Merged pull-requests count as closed pull-requests.
4
-
5
- jobs:
6
- create-new-version:
7
- runs-on: ubuntu-latest
8
- name: Create new version/tag
9
- steps:
10
- - uses: actions/checkout@v2
11
- if: github.event.pull_request.merged # Only run on merged pull-requests
12
- with:
13
- ref: ${{ github.event.pull_request.merge_commit_sha }} # Checkout the merged commit
14
- fetch-depth: 0
15
- token: ${{ secrets.ORIGAMI_VERSION_TOKEN }}
16
- - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* # Get all tags from the origin
17
- if: github.event.pull_request.merged # Only run on merged pull-requests
18
- - uses: Financial-Times/origami-version@v1.2.0
19
- name: Create new version/tag
20
- if: github.event.pull_request.merged # Only run on merged pull-requests
21
- with:
22
- github-token: ${{ secrets.ORIGAMI_GITHUB_TOKEN }}
@@ -1,40 +0,0 @@
1
- name: automerge
2
- on:
3
- pull_request:
4
- types:
5
- - labeled
6
- - unlabeled
7
- - synchronize
8
- - opened
9
- - edited
10
- - ready_for_review
11
- - reopened
12
- - unlocked
13
- pull_request_review:
14
- types:
15
- - submitted
16
- check_suite:
17
- types:
18
- - completed
19
- status: {}
20
- jobs:
21
- automerge:
22
- runs-on: ubuntu-latest
23
- if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
24
- timeout-minutes: 120
25
- steps:
26
- - name: 'Wait for status checks'
27
- id: waitforstatuschecks
28
- uses: "WyriHaximus/github-action-wait-for-status@v1.3"
29
- with:
30
- ignoreActions: automerge
31
- checkInterval: 13
32
- env:
33
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
34
- - name: automerge
35
- uses: "pascalgn/automerge-action@v0.13.0"
36
- env:
37
- GITHUB_TOKEN: "${{ secrets.ORIGAMI_GITHUB_TOKEN }}"
38
- MERGE_LABELS: "dependencies"
39
- MERGE_METHOD: "rebase"
40
- MERGE_FORKS: "false"
@@ -1,22 +0,0 @@
1
- name: npm audit fix
2
-
3
- on:
4
- schedule:
5
- - cron: 0 0 * * * # Runs at 00:00 UTC every day
6
-
7
- # on:
8
- # push:
9
- # branches:
10
- # - master
11
-
12
- jobs:
13
- run:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v2
17
- - uses: ybiquitous/npm-audit-fix-action@v2.1.6
18
- with:
19
- github_token: ${{ secrets.ORIGAMI_GITHUB_TOKEN }}
20
- # branch: "npm-audit-fix"
21
- # default_branch: master
22
- # commit_title: "chore(deps): npm audit fix"
@@ -1,22 +0,0 @@
1
- name: Publish to npm as latest version
2
- on:
3
- push:
4
- tags:
5
- - 'v[0-9]+.[0-9]+.[0-9]+' # non-prerelease tag
6
- jobs:
7
- publish-latest:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/checkout@v2
11
- - uses: actions/setup-node@v2.1.4
12
- with:
13
- node-version: '12.x'
14
- registry-url: 'https://registry.npmjs.org'
15
- - run: npm ci
16
- - name: Get the version
17
- id: version
18
- run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
19
- - run: npm version --no-git-tag-version ${{ steps.version.outputs.VERSION }}
20
- - run: npm publish
21
- env:
22
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,22 +0,0 @@
1
- name: Publish to npm as prerelease version
2
- on:
3
- push:
4
- tags:
5
- - 'v[0-9]+.[0-9]+.[0-9]+-*' # prerelease tag
6
- jobs:
7
- publish-prerelease:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/checkout@v2
11
- - uses: actions/setup-node@v2.1.4
12
- with:
13
- node-version: '12.x'
14
- registry-url: 'https://registry.npmjs.org'
15
- - run: npm ci
16
- - name: Get the version
17
- id: version
18
- run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
19
- - run: npm version --no-git-tag-version ${{ steps.version.outputs.VERSION }}
20
- - run: npm publish --tag prerelease
21
- env:
22
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,13 +0,0 @@
1
- name: Sync Origami labels
2
- on:
3
- - issues
4
- - pull_request_target
5
- - pull_request
6
- jobs:
7
- sync-labels:
8
- runs-on: ubuntu-latest
9
- name: Sync repository labels
10
- steps:
11
- - uses: Financial-Times/origami-labels@v1
12
- with:
13
- github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -1,11 +0,0 @@
1
- name: Test
2
- on: [pull_request]
3
- jobs:
4
- build:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: actions/checkout@v2
8
- - uses: actions/setup-node@v2.1.4
9
- with:
10
- node-version: 12.x
11
- - run: npm cit
package/.snyk DELETED
@@ -1,170 +0,0 @@
1
- # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2
- version: v1.14.1
3
- ignore: {}
4
- # patches apply the minimum changes required to fix a vulnerability
5
- patch:
6
- SNYK-JS-LODASH-567746:
7
- - '@babel/core > lodash':
8
- patched: '2020-05-06T18:55:45.980Z'
9
- - '@babel/core > @babel/types > lodash':
10
- patched: '2020-05-06T18:55:45.980Z'
11
- - '@babel/core > @babel/generator > lodash':
12
- patched: '2020-05-06T18:55:45.980Z'
13
- - '@babel/core > @babel/traverse > lodash':
14
- patched: '2020-05-06T18:55:45.980Z'
15
- - '@babel/core > @babel/helper-module-transforms > lodash':
16
- patched: '2020-05-06T18:55:45.980Z'
17
- - '@financial-times/js-features-analyser > @babel/core > lodash':
18
- patched: '2020-05-06T18:55:45.980Z'
19
- - '@babel/core > @babel/generator > @babel/types > lodash':
20
- patched: '2020-05-06T18:55:45.980Z'
21
- - '@babel/core > @babel/traverse > @babel/types > lodash':
22
- patched: '2020-05-06T18:55:45.980Z'
23
- - '@babel/core > @babel/template > @babel/types > lodash':
24
- patched: '2020-05-06T18:55:45.980Z'
25
- - '@babel/core > @babel/helper-module-transforms > @babel/types > lodash':
26
- patched: '2020-05-06T18:55:45.980Z'
27
- - '@babel/core > @babel/helpers > @babel/types > lodash':
28
- patched: '2020-05-06T18:55:45.980Z'
29
- - '@financial-times/js-features-analyser > @babel/core > @babel/types > lodash':
30
- patched: '2020-05-06T18:55:45.980Z'
31
- - '@babel/core > @babel/traverse > @babel/generator > lodash':
32
- patched: '2020-05-06T18:55:45.980Z'
33
- - '@financial-times/js-features-analyser > @babel/core > @babel/generator > lodash':
34
- patched: '2020-05-06T18:55:45.980Z'
35
- - '@babel/core > @babel/helpers > @babel/traverse > lodash':
36
- patched: '2020-05-06T18:55:45.980Z'
37
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > lodash':
38
- patched: '2020-05-06T18:55:45.980Z'
39
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > lodash':
40
- patched: '2020-05-06T18:55:45.980Z'
41
- - '@babel/core > @babel/traverse > @babel/generator > @babel/types > lodash':
42
- patched: '2020-05-06T18:55:45.980Z'
43
- - '@financial-times/js-features-analyser > @babel/core > @babel/generator > @babel/types > lodash':
44
- patched: '2020-05-06T18:55:45.980Z'
45
- - '@babel/core > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
46
- patched: '2020-05-06T18:55:45.980Z'
47
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/types > lodash':
48
- patched: '2020-05-06T18:55:45.980Z'
49
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/types > lodash':
50
- patched: '2020-05-06T18:55:45.980Z'
51
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/types > lodash':
52
- patched: '2020-05-06T18:55:45.980Z'
53
- - '@babel/core > @babel/helper-module-transforms > @babel/template > @babel/types > lodash':
54
- patched: '2020-05-06T18:55:45.980Z'
55
- - '@financial-times/js-features-analyser > @babel/core > @babel/template > @babel/types > lodash':
56
- patched: '2020-05-06T18:55:45.980Z'
57
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/types > lodash':
58
- patched: '2020-05-06T18:55:45.980Z'
59
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/types > lodash':
60
- patched: '2020-05-06T18:55:45.980Z'
61
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/generator > lodash':
62
- patched: '2020-05-06T18:55:45.980Z'
63
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/generator > lodash':
64
- patched: '2020-05-06T18:55:45.980Z'
65
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-module-imports > @babel/types > lodash':
66
- patched: '2020-05-06T18:55:45.980Z'
67
- - '@babel/core > @babel/helpers > @babel/template > @babel/types > lodash':
68
- patched: '2020-05-06T18:55:45.980Z'
69
- - '@babel/core > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
70
- patched: '2020-05-06T18:55:45.980Z'
71
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-split-export-declaration > @babel/types > lodash':
72
- patched: '2020-05-06T18:55:45.980Z'
73
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-simple-access > @babel/types > lodash':
74
- patched: '2020-05-06T18:55:45.980Z'
75
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > lodash':
76
- patched: '2020-05-06T18:55:45.980Z'
77
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > lodash':
78
- patched: '2020-05-06T18:55:45.980Z'
79
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/generator > @babel/types > lodash':
80
- patched: '2020-05-06T18:55:45.980Z'
81
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/generator > @babel/types > lodash':
82
- patched: '2020-05-06T18:55:45.980Z'
83
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
84
- patched: '2020-05-06T18:55:45.980Z'
85
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
86
- patched: '2020-05-06T18:55:45.980Z'
87
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/types > lodash':
88
- patched: '2020-05-06T18:55:45.980Z'
89
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/types > lodash':
90
- patched: '2020-05-06T18:55:45.980Z'
91
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/types > lodash':
92
- patched: '2020-05-06T18:55:45.980Z'
93
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/template > @babel/types > lodash':
94
- patched: '2020-05-06T18:55:45.980Z'
95
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/generator > lodash':
96
- patched: '2020-05-06T18:55:45.980Z'
97
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/generator > lodash':
98
- patched: '2020-05-06T18:55:45.980Z'
99
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-module-imports > @babel/types > lodash':
100
- patched: '2020-05-06T18:55:45.980Z'
101
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/helper-member-expression-to-functions > @babel/types > lodash':
102
- patched: '2020-05-06T18:55:45.980Z'
103
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/helper-optimise-call-expression > @babel/types > lodash':
104
- patched: '2020-05-06T18:55:45.980Z'
105
- - '@babel/core > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
106
- patched: '2020-05-06T18:55:45.980Z'
107
- - '@babel/core > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
108
- patched: '2020-05-06T18:55:45.980Z'
109
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-simple-access > @babel/template > @babel/types > lodash':
110
- patched: '2020-05-06T18:55:45.980Z'
111
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/template > @babel/types > lodash':
112
- patched: '2020-05-06T18:55:45.980Z'
113
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
114
- patched: '2020-05-06T18:55:45.980Z'
115
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
116
- patched: '2020-05-06T18:55:45.980Z'
117
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-split-export-declaration > @babel/types > lodash':
118
- patched: '2020-05-06T18:55:45.980Z'
119
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-simple-access > @babel/types > lodash':
120
- patched: '2020-05-06T18:55:45.980Z'
121
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > lodash':
122
- patched: '2020-05-06T18:55:45.980Z'
123
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/generator > @babel/types > lodash':
124
- patched: '2020-05-06T18:55:45.980Z'
125
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/generator > @babel/types > lodash':
126
- patched: '2020-05-06T18:55:45.980Z'
127
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
128
- patched: '2020-05-06T18:55:45.980Z'
129
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
130
- patched: '2020-05-06T18:55:45.980Z'
131
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/types > lodash':
132
- patched: '2020-05-06T18:55:45.980Z'
133
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/generator > lodash':
134
- patched: '2020-05-06T18:55:45.980Z'
135
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/helper-member-expression-to-functions > @babel/types > lodash':
136
- patched: '2020-05-06T18:55:45.980Z'
137
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/helper-optimise-call-expression > @babel/types > lodash':
138
- patched: '2020-05-06T18:55:45.980Z'
139
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
140
- patched: '2020-05-06T18:55:45.980Z'
141
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
142
- patched: '2020-05-06T18:55:45.980Z'
143
- - '@babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
144
- patched: '2020-05-06T18:55:45.980Z'
145
- - '@financial-times/js-features-analyser > @babel/core > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
146
- patched: '2020-05-06T18:55:45.980Z'
147
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-simple-access > @babel/template > @babel/types > lodash':
148
- patched: '2020-05-06T18:55:45.980Z'
149
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
150
- patched: '2020-05-06T18:55:45.980Z'
151
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
152
- patched: '2020-05-06T18:55:45.980Z'
153
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/generator > @babel/types > lodash':
154
- patched: '2020-05-06T18:55:45.980Z'
155
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/types > lodash':
156
- patched: '2020-05-06T18:55:45.980Z'
157
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
158
- patched: '2020-05-06T18:55:45.980Z'
159
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
160
- patched: '2020-05-06T18:55:45.980Z'
161
- - '@babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
162
- patched: '2020-05-06T18:55:45.980Z'
163
- - '@financial-times/js-features-analyser > @babel/core > @babel/helpers > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
164
- patched: '2020-05-06T18:55:45.980Z'
165
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-split-export-declaration > @babel/types > lodash':
166
- patched: '2020-05-06T18:55:45.980Z'
167
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/helper-get-function-arity > @babel/types > lodash':
168
- patched: '2020-05-06T18:55:45.980Z'
169
- - '@financial-times/js-features-analyser > @babel/core > @babel/helper-module-transforms > @babel/helper-replace-supers > @babel/traverse > @babel/helper-function-name > @babel/template > @babel/types > lodash':
170
- patched: '2020-05-06T18:55:45.980Z'
package/origami.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "description": "Analyse your JavaScript file and generate a polyfill.io URL based on all the features that are being used from within the JavaScript file.",
3
- "origamiType": "cli",
4
- "origamiVersion": 1,
5
- "keywords": [
6
- "polyfills",
7
- "bundle",
8
- "generator",
9
- "analysis"
10
- ],
11
- "support": "https://github.com/Financial-Times/polyfill-service-url-builder/issues",
12
- "supportStatus": "active",
13
- "supportContact": {
14
- "email": "origami.support@ft.com",
15
- "slack": "financialtimes/origami-support"
16
- }
17
- }
@@ -1,66 +0,0 @@
1
- /* eslint-env jest */
2
-
3
- const generatePolyfillURL = require('../src/index');
4
-
5
- test('Adds a feature to the features querystring if it exists in polyfill-library', async () => {
6
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.forEach';
7
- const actual = await generatePolyfillURL(["Array.prototype.forEach"])
8
- expect(actual.message).toEqual(expected);
9
- });
10
-
11
- test('Does not add duplicated features to the features querystring', async () => {
12
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.forEach';
13
- const actual = await generatePolyfillURL(["Array.prototype.forEach", "Array.prototype.forEach"])
14
- expect(actual.message).toEqual(expected);
15
- });
16
-
17
- test('Does not add features to the features querystring which do not exist in polyfill-library', async () => {
18
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.forEach';
19
- const actual = await generatePolyfillURL(["Array.prototype.forEach", "Carrot"])
20
- expect(actual.message).toEqual(expected);
21
- });
22
-
23
- test('Adds a feature to the features querystring if it exists as an alias of a polyfill from within polyfill-library', async () => {
24
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=ArrayBuffer';
25
- const actual = await generatePolyfillURL(["ArrayBuffer"])
26
- expect(actual.message).toEqual(expected);
27
- });
28
-
29
- test('Adds an alias to the features querystring if it matches multiple features and does not includes polyfill which are not in the features array', async () => {
30
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=es2017';
31
- const actual = await generatePolyfillURL(["Object.entries",
32
- "Object.getOwnPropertyDescriptors",
33
- "Object.values",
34
- "String.prototype.padEnd",
35
- "String.prototype.padStart"
36
- ])
37
- expect(actual.message).toEqual(expected);
38
- });
39
-
40
- test('Adds the constructor of a feature to the features querystring if the specific feature does not exist from within polyfill-library', async () => {
41
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=DOMTokenList';
42
- const actual = await generatePolyfillURL([
43
- "DOMTokenList.prototype.add"
44
- ]);
45
- expect(actual.message).toEqual(expected);
46
- });
47
-
48
- test('Sorts the features in alphabetical order to make spotting changes when updating the url simpler', async () => {
49
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=Array.from,DOMTokenList,fetch,String.prototype.padStart,WeakSet';
50
- const actual = await generatePolyfillURL([
51
- "String.prototype.padStart",
52
- "fetch",
53
- "WeakSet.prototype.delete",
54
- "DOMTokenList.prototype.add",
55
- "Array.from"
56
- ]);
57
- expect(actual.message).toEqual(expected);
58
- });
59
-
60
- test('Accepts a browserlist array', async () => {
61
- const expected = 'https://polyfill.io/v3/polyfill.min.js?features=Array.from';
62
- const actual = await generatePolyfillURL([
63
- "Array.from"
64
- ], ["op_mini *"]);
65
- expect(actual.message).toEqual(expected);
66
- });