@adobe/aio-lib-web 4.2.0 → 5.1.0-pre.2022-06-06.59001447

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.
@@ -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
+
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ${{ matrix.os }}
15
15
  strategy:
16
16
  matrix:
17
- node-version: [10.x, 12.x, 14.x]
17
+ node-version: [12.x, 14.x]
18
18
  os: [ubuntu-latest, windows-latest]
19
19
 
20
20
  steps:
@@ -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
- require('dotenv').config()
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.bundler.bundle()
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
@@ -0,0 +1,2 @@
1
+ RUNTIME_NAMESPACE=
2
+ RUNTIME_AUTH=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-lib-web",
3
- "version": "4.2.0",
3
+ "version": "5.1.0-pre.2022-06-06.59001447",
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": ">=10.0.0"
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": "^2.0.0",
33
- "@adobe/aio-lib-core-logging": "^1.1.0",
34
- "@adobe/aio-lib-core-tvm": "^2.2.1",
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,21 +39,23 @@
39
39
  "klaw": "^3.0.0",
40
40
  "lodash.clonedeep": "^4.5.0",
41
41
  "mime-types": "^2.1.24",
42
- "parcel-bundler": "1.12.3"
42
+ "parcel": "2.5.0",
43
+ "regenerator-runtime": "^0.13.7"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/hapi__joi": "^16.0.2",
46
47
  "@types/jest": "^25.1.0",
47
- "eslint": "^6.5.1",
48
+ "eslint": "^7",
48
49
  "eslint-config-standard": "^14.1.0",
49
50
  "eslint-plugin-import": "^2.18.2",
50
51
  "eslint-plugin-jest": "^23.1.1",
51
52
  "eslint-plugin-node": "^11.0.0",
52
53
  "eslint-plugin-promise": "^4.2.1",
53
54
  "eslint-plugin-standard": "^4.0.1",
54
- "jest": "^24.9.0",
55
- "jsdoc-to-markdown": "^6.0.1",
55
+ "jest": "^27",
56
+ "jsdoc-to-markdown": "^7",
56
57
  "memfs": "^3.0.1",
57
58
  "node-fetch": "^2.6.1"
58
- }
59
- }
59
+ },
60
+ "prereleaseSha": "590014478f3c4b46555a58166d80f2b7e7cb4763"
61
+ }
package/src/build-web.js CHANGED
@@ -12,7 +12,7 @@ governing permissions and limitations under the License.
12
12
 
13
13
  const fs = require('fs-extra')
14
14
  const path = require('path')
15
- const Bundler = require('parcel-bundler')
15
+ const Bundler = require('@parcel/core').default
16
16
 
17
17
  /**
18
18
  * @deprecated since 4.1.0 ( January, 2021 ), use `bundle` instead
@@ -29,16 +29,19 @@ const buildWeb = async (config, log) => {
29
29
  await fs.emptyDir(dist)
30
30
 
31
31
  // 2. build files
32
- const bundler = new Bundler(path.join(src, 'index.html'), {
33
- cache: false,
34
- outDir: dist,
35
- publicUrl: './',
36
- watch: false,
37
- logLevel: 0,
38
- contentHash: true
32
+ const bundler = new Bundler({
33
+ entries: path.join(src, 'index.html'),
34
+ defaultConfig: require.resolve('@parcel/config-default'),
35
+ shouldDisableCache: true,
36
+ defaultTargetOptions: {
37
+ distDir: dist,
38
+ publicUrl: './'
39
+ },
40
+ logLevel: 'none',
41
+ shouldContentHash: true
39
42
  })
40
43
 
41
- await bundler.bundle()
44
+ await bundler.run()
42
45
 
43
46
  // 3. show built files ( if we are passed a log function )
44
47
  const files = await fs.readdir(dist)
package/src/bundle.js CHANGED
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- const Bundler = require('parcel-bundler')
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
  const fs = require('fs-extra')
16
16
  /**
@@ -37,7 +37,7 @@ const fs = require('fs-extra')
37
37
  * @param {Function} [log] the app logger
38
38
  * @returns {BundleWebObject} the BundleWebObject
39
39
  */
40
- module.exports = async (entryFile, dest, options = {}, log = () => {}) => {
40
+ module.exports = async (entryFile, dest, options = { shouldOptimize: false }, log = () => {}) => {
41
41
  aioLogger.debug(`bundle options: ${JSON.stringify(options, null, 2)}`)
42
42
 
43
43
  if (!entryFile || !fs.existsSync(entryFile)) {
@@ -49,26 +49,28 @@ 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
- cache: true,
53
- outDir: dest,
54
- contentHash: true, // false if dev, true if prod ??
55
- watch: false, // currently false if dev true if prod,
56
- minify: false,
57
- logLevel: 1,
52
+ entries: entryFile,
53
+ defaultConfig: require.resolve('@parcel/config-default'),
54
+ shouldDisableCache: false,
55
+ targets: {
56
+ webassets: {
57
+ includeNodeModules: true,
58
+ distDir: dest
59
+ }
60
+ },
61
+ defaultTargetOptions: {
62
+ distDir: dest,
63
+ shouldOptimize: options.shouldOptimize
64
+ },
65
+ shouldPatchConsole: false,
66
+ shouldContentHash: true,
67
+ logLevel: 'error',
58
68
  ...options
59
69
  }
60
70
 
61
71
  aioLogger.debug(`bundle bundleOptions: ${JSON.stringify(parcelBundleOptions, null, 2)}`)
62
72
  log(`bundling ${entryFile}`)
63
- const bundler = new Bundler(entryFile, parcelBundleOptions)
73
+ const bundler = new Bundler(parcelBundleOptions)
64
74
 
65
- const cleanup = async () => {
66
- aioLogger.debug('cleanup bundler...')
67
- await bundler.stop()
68
- }
69
-
70
- return {
71
- bundler,
72
- cleanup
73
- }
75
+ return bundler
74
76
  }
@@ -11,35 +11,35 @@ governing permissions and limitations under the License.
11
11
  */
12
12
 
13
13
  const mockBundle = jest.fn()
14
- const mockMiddleware = jest.fn()
15
14
  const mockConstructor = jest.fn()
16
15
  const mockServe = jest.fn()
17
- const mockStop = jest.fn()
18
16
 
19
17
  // hack to expose constructor, somehow returning a jest.fn doesn't work as expected for commonjs (only es6)
20
- const Bundler = function (...args) {
21
- mockConstructor(...args)
22
- global._bundler__arguments = args
23
- return {
24
- bundle: mockBundle,
25
- middleware: mockMiddleware,
26
- serve: mockServe,
27
- stop: mockStop
18
+ class core {
19
+ constructor (...args) {
20
+ mockConstructor(...args)
21
+ global._bundler__arguments = args
22
+ }
23
+
24
+ run () {
25
+ mockBundle()
26
+ }
27
+
28
+ watch () {
29
+ mockServe()
28
30
  }
29
31
  }
30
- Bundler.mockBundle = mockBundle
31
- Bundler.mockConstructor = mockConstructor
32
- Bundler.mockMiddleware = mockMiddleware
33
- Bundler.mockServe = mockServe
34
- Bundler.mockStop = mockStop
32
+ core.mockBundle = mockBundle
33
+ core.mockConstructor = mockConstructor
34
+ core.mockServe = mockServe
35
35
 
36
36
  // alias
37
- Bundler.mockReset = () => {
38
- Bundler.mockConstructor.mockReset()
39
- Bundler.mockBundle.mockReset()
40
- Bundler.mockMiddleware.mockReset()
41
- Bundler.mockServe.mockReset()
42
- Bundler.mockStop.mockReset()
37
+ core.mockReset = () => {
38
+ core.mockConstructor.mockReset()
39
+ core.mockBundle.mockReset()
40
+ core.mockServe.mockReset()
43
41
  }
44
42
 
45
- module.exports = Bundler
43
+ module.exports = {
44
+ default: core
45
+ }
@@ -63,6 +63,18 @@ describe('build-web', () => {
63
63
  global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
64
64
  fs.readdir.mockReturnValue(['output.html'])
65
65
  await expect(buildWeb(config)).resolves.toEqual(['output.html'])
66
- expect(global._bundler__arguments).toEqual([path.join('fakeDir', 'index.html'), { cache: false, contentHash: true, logLevel: 0, outDir: 'dist', publicUrl: './', watch: false }])
66
+ expect(global._bundler__arguments).toEqual([
67
+ expect.objectContaining({
68
+ defaultConfig: expect.stringContaining(path.join('parcel', 'config-default', 'index.json')),
69
+ defaultTargetOptions: expect.objectContaining({
70
+ distDir: 'dist',
71
+ publicUrl: './'
72
+ }),
73
+ entries: path.join('fakeDir', 'index.html'),
74
+ logLevel: 'none',
75
+ shouldContentHash: true,
76
+ shouldDisableCache: true
77
+ })
78
+ ])
67
79
  })
68
80
  })
@@ -14,6 +14,7 @@ const { vol } = global.mockFs()
14
14
  const bundle = require('../../src/bundle')
15
15
  const fs = require('fs-extra')
16
16
  jest.mock('fs-extra')
17
+ const path = require('path')
17
18
 
18
19
  describe('bundle', () => {
19
20
  beforeEach(() => {
@@ -49,43 +50,59 @@ describe('bundle', () => {
49
50
 
50
51
  test('check build options', async () => {
51
52
  global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
52
- await expect(bundle('fakeDir/index.html', 'distProd')).resolves.toEqual(
53
- expect.objectContaining({ bundler: expect.any(Object) }))
53
+ await expect(bundle('fakeDir/index.html', 'distProd')).resolves.toEqual(expect.any(Object))
54
54
  expect(global._bundler__arguments).toEqual([
55
- expect.stringContaining('fakeDir'),
56
55
  expect.objectContaining({
57
- cache: true,
58
- contentHash: true,
59
- logLevel: 1,
60
- outDir: 'distProd',
61
- watch: false
56
+ defaultConfig: expect.stringContaining(path.join('parcel', 'config-default', 'index.json')),
57
+ defaultTargetOptions: expect.objectContaining({
58
+ distDir: 'distProd',
59
+ shouldOptimize: false
60
+ }),
61
+ entries: 'fakeDir/index.html',
62
+ logLevel: 'error',
63
+ shouldContentHash: true,
64
+ shouldDisableCache: false
62
65
  })])
63
66
  })
64
67
 
65
68
  test('uses build options', async () => {
66
69
  global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
67
- await expect(bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5 }))
68
- .resolves.toEqual(expect.objectContaining({ bundler: expect.any(Object) }))
70
+ await expect(bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5, shouldOptimize: false }))
71
+ .resolves.toEqual(expect.any(Object))
69
72
  expect(global._bundler__arguments).toEqual([
70
- expect.stringContaining('fakeDir'),
71
73
  expect.objectContaining({
72
- cache: true,
73
- contentHash: false,
74
- logLevel: 5,
75
- outDir: 'distProd',
76
- watch: false
74
+ defaultConfig: expect.stringContaining(path.join('parcel', 'config-default', 'index.json')),
75
+ defaultTargetOptions: expect.objectContaining({
76
+ distDir: 'distProd',
77
+ shouldOptimize: false
78
+ }),
79
+ entries: 'fakeDir/index.html',
80
+ shouldContentHash: true,
81
+ shouldDisableCache: false
82
+ })])
83
+ })
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
77
99
  })])
78
100
  })
79
101
 
80
102
  test('returns {bundle, cleanup}', async () => {
81
103
  global.addFakeFiles(vol, 'fakeDir', { 'index.html': '' })
82
104
 
83
- const { bundler, cleanup } = await bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5 })
105
+ const bundler = await bundle('fakeDir/index.html', 'distProd', { contentHash: false, logLevel: 5 })
84
106
  expect(bundler).toBeDefined()
85
- expect(cleanup).toBeDefined()
86
- expect(typeof cleanup).toBe('function')
87
- bundler.stop = jest.fn()
88
- cleanup()
89
- expect(bundler.stop).toHaveBeenCalled()
90
107
  })
91
108
  })