@adobe/aio-lib-web 5.0.0 → 5.1.0-pre.2022-06-07.ebbc614c
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.
- package/.github/workflows/daily.yml +34 -0
- package/.github/workflows/node.js.yml +1 -1
- package/.github/workflows/prerelease.yml +45 -0
- package/e2e/e2e.js +8 -2
- package/e2e/env.sample +2 -0
- package/package.json +12 -11
- package/src/bundle.js +8 -8
- package/test/src/bundle.test.js +18 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Daily - Do npm install and run all unit tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
# run daily at midnight
|
|
6
|
+
- cron: '0 0 * * *'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ${{ matrix.os }}
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
node: [14]
|
|
14
|
+
os: [ubuntu-latest]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v2
|
|
18
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
+
uses: actions/setup-node@v1
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
- run: npm i --package-lock --package-lock-only
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- name: run unit tests
|
|
25
|
+
run: npm run test
|
|
26
|
+
- name: Slack Notification
|
|
27
|
+
if: ${{ failure() }}
|
|
28
|
+
uses: rtCamp/action-slack-notify@v2
|
|
29
|
+
env:
|
|
30
|
+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
|
31
|
+
SLACK_TITLE: 'Node version'
|
|
32
|
+
SLACK_MESSAGE: ${{ matrix.node }}
|
|
33
|
+
SLACK_COLOR: ${{ job.status == 'success' && 'good' || job.status == 'cancelled' && '#808080' || 'danger' }}
|
|
34
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: publish-prerelease
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
pre-release-tag:
|
|
6
|
+
description: 'The pre-release tag use in the version'
|
|
7
|
+
required: false
|
|
8
|
+
default: 'pre'
|
|
9
|
+
dist-tag:
|
|
10
|
+
description: 'The dist-tag use'
|
|
11
|
+
required: false
|
|
12
|
+
default: 'next'
|
|
13
|
+
dependencies-to-update:
|
|
14
|
+
description: 'csv of dependencies to update with the dist-tag'
|
|
15
|
+
required: false
|
|
16
|
+
default: '@adobe/aio-lib-core-config,@adobe/aio-lib-core-logging,@adobe/aio-lib-core-tvm'
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
checkout:
|
|
20
|
+
name: checkout
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- run: |
|
|
25
|
+
git config user.name github-actions
|
|
26
|
+
git config user.email github-actions@github.com
|
|
27
|
+
- uses: actions/setup-node@v1
|
|
28
|
+
with:
|
|
29
|
+
node-version: 16
|
|
30
|
+
- run: |
|
|
31
|
+
npm install
|
|
32
|
+
npm test
|
|
33
|
+
- name: Update your package.json with an npm pre-release version
|
|
34
|
+
id: pre-release-version
|
|
35
|
+
uses: adobe/update-prerelease-npm-version@v1.0.0
|
|
36
|
+
with:
|
|
37
|
+
pre-release-tag: ${{ github.event.inputs.pre-release-tag }}
|
|
38
|
+
dependencies-to-update: ${{ github.event.inputs.dependencies-to-update }}
|
|
39
|
+
dependencies-to-update-version-tag: ${{ github.event.inputs.dist-tag }}
|
|
40
|
+
- run: echo pre-release-version - ${{ steps.pre-release-version.outputs.pre-release-version }}
|
|
41
|
+
- uses: JS-DevTools/npm-publish@v1
|
|
42
|
+
with:
|
|
43
|
+
token: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
|
|
44
|
+
tag: ${{ github.event.inputs.dist-tag }}
|
|
45
|
+
access: 'public'
|
package/e2e/e2e.js
CHANGED
|
@@ -13,7 +13,11 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
const path = require('path')
|
|
14
14
|
const fs = require('fs-extra')
|
|
15
15
|
const fetch = require('node-fetch')
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
jest.setTimeout(30000)
|
|
18
|
+
|
|
19
|
+
// load .env values in the e2e folder, if any
|
|
20
|
+
require('dotenv').config({ path: path.join(__dirname, '.env') })
|
|
17
21
|
|
|
18
22
|
const bundle = require('../src/bundle')
|
|
19
23
|
const deployWeb = require('../src/deploy-web')
|
|
@@ -61,7 +65,7 @@ describe('e2e', () => {
|
|
|
61
65
|
DEST_FOLDER,
|
|
62
66
|
{}
|
|
63
67
|
)
|
|
64
|
-
await parcelBundle.
|
|
68
|
+
await parcelBundle.run()
|
|
65
69
|
} catch (e) {
|
|
66
70
|
error = e
|
|
67
71
|
console.error(e)
|
|
@@ -84,6 +88,7 @@ describe('e2e', () => {
|
|
|
84
88
|
contents = await response.text()
|
|
85
89
|
} catch (e) {
|
|
86
90
|
error = e
|
|
91
|
+
console.error(e)
|
|
87
92
|
}
|
|
88
93
|
expect(error).toBeUndefined()
|
|
89
94
|
expect(url).not.toBeNull()
|
|
@@ -98,6 +103,7 @@ describe('e2e', () => {
|
|
|
98
103
|
response = await fetch(url)
|
|
99
104
|
} catch (e) {
|
|
100
105
|
error = e
|
|
106
|
+
console.error(e)
|
|
101
107
|
}
|
|
102
108
|
expect(error).toBeUndefined()
|
|
103
109
|
expect(response.status).toEqual(404)
|
package/e2e/env.sample
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/aio-lib-web",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.1.0-pre.2022-06-07.ebbc614c",
|
|
4
4
|
"description": "Utility tooling library to build and deploy Adobe I/O Project Firefly app static sites to CDN",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Adobe Inc.",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=12.2.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": "adobe/aio-lib-web",
|
|
16
16
|
"homepage": "https://github.com/adobe/aio-lib-web",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"e2e": "jest --config='./e2e/jest.config.js' --testRegex './e2e/e2e.js'"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@adobe/aio-lib-core-config": "
|
|
33
|
-
"@adobe/aio-lib-core-logging": "
|
|
34
|
-
"@adobe/aio-lib-core-tvm": "
|
|
32
|
+
"@adobe/aio-lib-core-config": "next",
|
|
33
|
+
"@adobe/aio-lib-core-logging": "next",
|
|
34
|
+
"@adobe/aio-lib-core-tvm": "next",
|
|
35
35
|
"aws-sdk": "^2.600.0",
|
|
36
36
|
"fs-extra": "^9.0.0",
|
|
37
37
|
"joi": "^17.2.1",
|
|
@@ -39,22 +39,23 @@
|
|
|
39
39
|
"klaw": "^3.0.0",
|
|
40
40
|
"lodash.clonedeep": "^4.5.0",
|
|
41
41
|
"mime-types": "^2.1.24",
|
|
42
|
-
"parcel": "2.
|
|
42
|
+
"parcel": "2.5.0",
|
|
43
43
|
"regenerator-runtime": "^0.13.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/hapi__joi": "^16.0.2",
|
|
47
47
|
"@types/jest": "^25.1.0",
|
|
48
|
-
"eslint": "^
|
|
48
|
+
"eslint": "^7",
|
|
49
49
|
"eslint-config-standard": "^14.1.0",
|
|
50
50
|
"eslint-plugin-import": "^2.18.2",
|
|
51
51
|
"eslint-plugin-jest": "^23.1.1",
|
|
52
52
|
"eslint-plugin-node": "^11.0.0",
|
|
53
53
|
"eslint-plugin-promise": "^4.2.1",
|
|
54
54
|
"eslint-plugin-standard": "^4.0.1",
|
|
55
|
-
"jest": "^
|
|
56
|
-
"jsdoc-to-markdown": "^
|
|
55
|
+
"jest": "^27",
|
|
56
|
+
"jsdoc-to-markdown": "^7",
|
|
57
57
|
"memfs": "^3.0.1",
|
|
58
58
|
"node-fetch": "^2.6.1"
|
|
59
|
-
}
|
|
60
|
-
|
|
59
|
+
},
|
|
60
|
+
"prereleaseSha": "ebbc614c694276aea7577b8afe0a486c67736639"
|
|
61
|
+
}
|
package/src/bundle.js
CHANGED
|
@@ -12,7 +12,7 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
const Bundler = require('@parcel/core').default
|
|
14
14
|
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-lib-web:bundle', { provider: 'debug' })
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
/**
|
|
17
17
|
* @typedef {object} BundleWebObject
|
|
18
18
|
* @property {object} the Parcel bundler object
|
|
@@ -31,17 +31,17 @@ const fs = require('fs-extra')
|
|
|
31
31
|
/**
|
|
32
32
|
* Bundles the web source via Parcel.
|
|
33
33
|
*
|
|
34
|
-
* @param {string} [
|
|
34
|
+
* @param {Array of string} [entries] one or more file paths or globs
|
|
35
35
|
* @param {string} [dest] directory to build to
|
|
36
36
|
* @param {BundleOptions} [options] the Parcel bundler options
|
|
37
37
|
* @param {Function} [log] the app logger
|
|
38
38
|
* @returns {BundleWebObject} the BundleWebObject
|
|
39
39
|
*/
|
|
40
|
-
module.exports = async (
|
|
40
|
+
module.exports = async (entries, dest, options = { shouldOptimize: false }, log = () => {}) => {
|
|
41
41
|
aioLogger.debug(`bundle options: ${JSON.stringify(options, null, 2)}`)
|
|
42
42
|
|
|
43
|
-
if (!
|
|
44
|
-
throw new Error('cannot build web,
|
|
43
|
+
if (!entries) {
|
|
44
|
+
throw new Error('cannot build web, entries not specified')
|
|
45
45
|
}
|
|
46
46
|
if (!dest) {
|
|
47
47
|
throw new Error('cannot build web, missing destination')
|
|
@@ -49,7 +49,7 @@ module.exports = async (entryFile, dest, options = {}, log = () => {}) => {
|
|
|
49
49
|
|
|
50
50
|
// set defaults, but allow override by passed in values
|
|
51
51
|
const parcelBundleOptions = {
|
|
52
|
-
entries:
|
|
52
|
+
entries: entries,
|
|
53
53
|
defaultConfig: require.resolve('@parcel/config-default'),
|
|
54
54
|
shouldDisableCache: false,
|
|
55
55
|
targets: {
|
|
@@ -60,7 +60,7 @@ module.exports = async (entryFile, dest, options = {}, log = () => {}) => {
|
|
|
60
60
|
},
|
|
61
61
|
defaultTargetOptions: {
|
|
62
62
|
distDir: dest,
|
|
63
|
-
shouldOptimize:
|
|
63
|
+
shouldOptimize: options.shouldOptimize
|
|
64
64
|
},
|
|
65
65
|
shouldPatchConsole: false,
|
|
66
66
|
shouldContentHash: true,
|
|
@@ -69,7 +69,7 @@ module.exports = async (entryFile, dest, options = {}, log = () => {}) => {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
aioLogger.debug(`bundle bundleOptions: ${JSON.stringify(parcelBundleOptions, null, 2)}`)
|
|
72
|
-
log(`bundling ${
|
|
72
|
+
log(`bundling ${entries}`)
|
|
73
73
|
const bundler = new Bundler(parcelBundleOptions)
|
|
74
74
|
|
|
75
75
|
return bundler
|
package/test/src/bundle.test.js
CHANGED
|
@@ -67,7 +67,7 @@ describe('bundle', () => {
|
|
|
67
67
|
|
|
68
68
|
test('uses build options', async () => {
|
|
69
69
|
global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
|
|
70
|
-
await expect(bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5 }))
|
|
70
|
+
await expect(bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5, shouldOptimize: false }))
|
|
71
71
|
.resolves.toEqual(expect.any(Object))
|
|
72
72
|
expect(global._bundler__arguments).toEqual([
|
|
73
73
|
expect.objectContaining({
|
|
@@ -82,6 +82,23 @@ describe('bundle', () => {
|
|
|
82
82
|
})])
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
+
test('uses build options - shouldOptimize', async () => {
|
|
86
|
+
global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
|
|
87
|
+
await expect(bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5, shouldOptimize: true }))
|
|
88
|
+
.resolves.toEqual(expect.any(Object))
|
|
89
|
+
expect(global._bundler__arguments).toEqual([
|
|
90
|
+
expect.objectContaining({
|
|
91
|
+
defaultConfig: expect.stringContaining(path.join('parcel', 'config-default', 'index.json')),
|
|
92
|
+
defaultTargetOptions: expect.objectContaining({
|
|
93
|
+
distDir: 'distProd',
|
|
94
|
+
shouldOptimize: true
|
|
95
|
+
}),
|
|
96
|
+
entries: 'fakeDir/index.html',
|
|
97
|
+
shouldContentHash: true,
|
|
98
|
+
shouldDisableCache: false
|
|
99
|
+
})])
|
|
100
|
+
})
|
|
101
|
+
|
|
85
102
|
test('returns {bundle, cleanup}', async () => {
|
|
86
103
|
global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
|
|
87
104
|
|