diff --git a/package.json b/package.json index 7e9661d6..9fe45b43 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,11 @@ "author": "Adobe Inc.", "bugs": "https://github.com/adobe/aio-cli-plugin-app/issues", "dependencies": { - "@adobe/aio-app-scripts": "purplecabbage/aio-app-scripts#remove-web-config-writing", "@adobe/aio-lib-core-config": "^2.0.0", "@adobe/aio-lib-core-logging": "^1.1.0", "@adobe/aio-lib-ims": "^4.1.0", - "@adobe/aio-lib-runtime": "purplecabbage/aio-lib-runtime#build-deploy-actions", + "@adobe/aio-lib-runtime": "^1.0.0-0", + "@adobe/aio-lib-web": "^3.0.0", "@adobe/generator-aio-app": "^1.7.0", "@adobe/generator-aio-console": "^1.1.1", "@oclif/command": "^1.5.11", diff --git a/src/commands/app/deploy.js b/src/commands/app/deploy.js index efe13135..f1677672 100644 --- a/src/commands/app/deploy.js +++ b/src/commands/app/deploy.js @@ -17,7 +17,7 @@ const fs = require('fs-extra') const { cli } = require('cli-ux') const BaseCommand = require('../../BaseCommand') -const AppScripts = require('@adobe/aio-app-scripts') +const webLib = require('@adobe/aio-lib-web') const { flags } = require('@oclif/command') const { runPackageScript, wrapError, writeConfig } = require('../../lib/app-helper') const rtLib = require('@adobe/aio-lib-runtime') @@ -65,7 +65,7 @@ class Deploy extends BaseCommand { await writeConfig(config.web.injectedConfig, urls) } spinner.start('Building web assets') - await AppScripts.buildWeb(config, onProgress) + await webLib.buildWeb(config, onProgress) spinner.succeed(chalk.green('Building web assets')) } else { this.log('no web-src, skipping web-src build') @@ -107,7 +107,7 @@ class Deploy extends BaseCommand { if (!flags['skip-static']) { if (fs.existsSync('web-src/')) { spinner.start('Deploying web assets') - deployedFrontendUrl = await AppScripts.deployWeb(config, onProgress) + deployedFrontendUrl = await webLib.deployWeb(config, onProgress) spinner.succeed(chalk.green('Deploying web assets')) } else { this.log('no web-src, skipping web-src deploy') diff --git a/src/commands/app/run.js b/src/commands/app/run.js index 2d8e77a1..8a18f5c9 100644 --- a/src/commands/app/run.js +++ b/src/commands/app/run.js @@ -21,7 +21,6 @@ const { flags } = require('@oclif/command') const coreConfig = require('@adobe/aio-lib-core-config') const BaseCommand = require('../../BaseCommand') -// const AppScripts = require('@adobe/aio-app-scripts') const runDev = require('../../lib/runDev') const { runPackageScript, wrapError } = require('../../lib/app-helper') diff --git a/src/commands/app/undeploy.js b/src/commands/app/undeploy.js index c3dc3fea..06fb613e 100644 --- a/src/commands/app/undeploy.js +++ b/src/commands/app/undeploy.js @@ -18,7 +18,7 @@ const fs = require('fs-extra') const { flags } = require('@oclif/command') const BaseCommand = require('../../BaseCommand') -const AppScripts = require('@adobe/aio-app-scripts') +const webLib = require('@adobe/aio-lib-web') const { wrapError } = require('../../lib/app-helper') const rtLib = require('@adobe/aio-lib-runtime') @@ -47,7 +47,7 @@ class Undeploy extends BaseCommand { } if (!flags['skip-static']) { if (fs.existsSync('web-src/')) { - await AppScripts.undeployWeb(config, onProgress) + await webLib.undeployWeb(config, onProgress) } else { this.log('no web-src, skipping web-src undeploy') } diff --git a/src/lib/owlocal.js b/src/lib/owlocal.js index 45883060..645381d4 100644 --- a/src/lib/owlocal.js +++ b/src/lib/owlocal.js @@ -11,7 +11,7 @@ governing permissions and limitations under the License. */ const path = require('path') -const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-app-scripts:owlocal', { provider: 'debug' }) +const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:owlocal', { provider: 'debug' }) const execa = require('execa') const OW_LOCAL_DOCKER_PORT = 3233 diff --git a/test/__mocks__/@adobe/aio-app-scripts.js b/test/__mocks__/@adobe/aio-lib-web.js similarity index 62% rename from test/__mocks__/@adobe/aio-app-scripts.js rename to test/__mocks__/@adobe/aio-lib-web.js index 559ffd38..8deff840 100644 --- a/test/__mocks__/@adobe/aio-app-scripts.js +++ b/test/__mocks__/@adobe/aio-lib-web.js @@ -10,23 +10,23 @@ OF ANY KIND, either express or implied. See the License for the specific languag governing permissions and limitations under the License. */ -const mockScripts = { +const mockLibWeb = { buildWeb: jest.fn(), deployWeb: jest.fn(), undeployWeb: jest.fn() } -mockScripts.mockReset = (script) => { - mockScripts[script].mockReset() - mockScripts[script].mockImplementation() +mockLibWeb.mockReset = (script) => { + mockLibWeb[script].mockReset() + mockLibWeb[script].mockImplementation() } -mockScripts.mockResolvedValue = (script, value) => { - mockScripts[script].mockImplementation(async () => { return value }) +mockLibWeb.mockResolvedValue = (script, value) => { + mockLibWeb[script].mockImplementation(async () => { return value }) } -mockScripts.mockRejectedValue = (script, value) => { - mockScripts[script].mockImplementation(async () => { throw value }) +mockLibWeb.mockRejectedValue = (script, value) => { + mockLibWeb[script].mockImplementation(async () => { throw value }) } -module.exports = mockScripts +module.exports = mockLibWeb diff --git a/test/__mocks__/parcel-bundler.js b/test/__mocks__/parcel-bundler.js index 109417ff..25afe82c 100644 --- a/test/__mocks__/parcel-bundler.js +++ b/test/__mocks__/parcel-bundler.js @@ -10,9 +10,6 @@ OF ANY KIND, either express or implied. See the License for the specific languag governing permissions and limitations under the License. */ -// need to manually mock because parcel seems to fs read -// /Users/mraho/work/aio-app-scripts/node_modules/grapheme-breaker/src/classes.trie which conflicts with fs mocking - const mockBundle = jest.fn() const mockMiddleware = jest.fn() const mockConstructor = jest.fn() diff --git a/test/commands/app/deploy.test.js b/test/commands/app/deploy.test.js index 50468749..b5a5558b 100644 --- a/test/commands/app/deploy.test.js +++ b/test/commands/app/deploy.test.js @@ -18,7 +18,7 @@ const mockFS = require('fs-extra') jest.mock('../../../src/lib/app-helper.js') const helpers = require('../../../src/lib/app-helper.js') -const mockScripts = require('@adobe/aio-app-scripts') +const mockWebLib = require('@adobe/aio-lib-web') const mockRuntimeLib = require('@adobe/aio-lib-runtime') jest.mock('@adobe/aio-lib-core-config') @@ -28,8 +28,8 @@ jest.mock('cli-ux') const { cli } = require('cli-ux') beforeEach(() => { - mockScripts.mockReset('deployWeb') - mockScripts.mockReset('buildWeb') + mockWebLib.mockReset('deployWeb') + mockWebLib.mockReset('buildWeb') mockFS.existsSync.mockReset() helpers.writeConfig.mockReset() jest.restoreAllMocks() @@ -91,9 +91,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('build & deploy an App verbose', async () => { @@ -102,9 +102,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('build & deploy --skip-static', async () => { @@ -113,9 +113,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('build & deploy only some actions using --action', async () => { @@ -124,9 +124,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledWith({}, ['a', 'b', 'c']) expect(mockRuntimeLib.deployActions).toHaveBeenCalledWith({}, { @@ -141,9 +141,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('build & deploy actions with no actions folder but with a manifest', async () => { @@ -152,9 +152,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('build & deploy with --skip-actions', async () => { @@ -163,9 +163,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('build & deploy with --skip-actions with no static folder', async () => { @@ -174,9 +174,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('--skip-deploy', async () => { @@ -185,9 +185,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('--skip-deploy --verbose', async () => { @@ -196,9 +196,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('--skip-deploy --skip-actions', async () => { @@ -207,9 +207,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) }) test('--skip-deploy --skip-static', async () => { @@ -218,9 +218,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('--skip-build', async () => { @@ -229,9 +229,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('--skip-build --verbose', async () => { @@ -240,9 +240,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('--skip-build --skip-actions', async () => { @@ -251,9 +251,9 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('--skip-build --skip-static', async () => { @@ -262,14 +262,14 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(0) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(0) }) test('deploy should show ui url', async () => { mockFS.existsSync.mockReturnValue(true) - mockScripts.deployWeb.mockResolvedValue('https://example.com') + mockWebLib.deployWeb.mockResolvedValue('https://example.com') command.argv = [] await command.run() expect(command.error).toHaveBeenCalledTimes(0) @@ -279,7 +279,7 @@ describe('run', () => { test('deploy should open ui url with --open', async () => { cli.open = jest.fn() mockFS.existsSync.mockReturnValue(true) - mockScripts.deployWeb.mockResolvedValue('https://example.com') + mockWebLib.deployWeb.mockResolvedValue('https://example.com') command.argv = ['--open'] await command.run() expect(command.error).toHaveBeenCalledTimes(0) @@ -289,7 +289,7 @@ describe('run', () => { test('deploy should show ui and exc url if AIO_LAUNCH_PREFIX_URL is set', async () => { mockFS.existsSync.mockReturnValue(true) - mockScripts.deployWeb.mockResolvedValue('https://example.com') + mockWebLib.deployWeb.mockResolvedValue('https://example.com') mockConfig.get.mockReturnValue('http://prefix?fake=') command.argv = [] await command.run() @@ -300,7 +300,7 @@ describe('run', () => { test('deploy should show ui and open exc url if AIO_LAUNCH_PREFIX_URL is set and --open', async () => { mockFS.existsSync.mockReturnValue(true) - mockScripts.deployWeb.mockResolvedValue('https://example.com') + mockWebLib.deployWeb.mockResolvedValue('https://example.com') mockConfig.get.mockReturnValue('http://prefix?fake=') cli.open = jest.fn() command.argv = ['--open'] @@ -333,7 +333,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledWith(error) expect(mockRuntimeLib.buildActions).toHaveBeenCalledTimes(1) - expect(mockScripts.buildWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.buildWeb).toHaveBeenCalledTimes(1) expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1) }) @@ -341,39 +341,39 @@ describe('run', () => { mockFS.existsSync.mockReturnValue(true) const error = new Error('mock failure') mockRuntimeLib.deployActions.mockResolvedValue('ok') - mockScripts.deployWeb.mockRejectedValue(error) + mockWebLib.deployWeb.mockRejectedValue(error) await command.run() expect(command.error).toHaveBeenCalledWith(error) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) }) test('spinner should be called for progress logs on deployWeb call , with verbose', async () => { mockFS.existsSync.mockReturnValue(true) mockRuntimeLib.deployActions.mockResolvedValue('ok') - mockScripts.deployWeb.mockImplementation(async (config, log) => { + mockWebLib.deployWeb.mockImplementation(async (config, log) => { log('progress log') return 'ok' }) command.argv = ['-v'] await command.run() - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) }) test('spinner should be called for progress logs on deployWeb call , without verbose', async () => { mockFS.existsSync.mockReturnValue(true) mockRuntimeLib.deployActions.mockResolvedValue('ok') - mockScripts.deployWeb.mockImplementation(async (config, log) => { + mockWebLib.deployWeb.mockImplementation(async (config, log) => { log('progress log') return 'ok' }) await command.run() - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) }) test('write web-src/src/config.json with action urls after buildActions and before buildWeb', async () => { mockFS.existsSync.mockReturnValue(true) mockRuntimeLib.deployActions.mockResolvedValue('ok') - mockScripts.deployWeb.mockImplementation(async (config, log) => { + mockWebLib.deployWeb.mockImplementation(async (config, log) => { log('progress log') return 'ok' }) @@ -385,6 +385,6 @@ describe('run', () => { await command.run() expect(mockRuntimeLib.utils.getActionUrls).toHaveBeenCalledTimes(1) expect(helpers.writeConfig).toHaveBeenCalledWith('sdf', { a: 'a' }) - expect(mockScripts.deployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1) }) }) diff --git a/test/commands/app/run.test.js b/test/commands/app/run.test.js index aff131ac..49c215a9 100644 --- a/test/commands/app/run.test.js +++ b/test/commands/app/run.test.js @@ -37,8 +37,6 @@ const https = require('https') jest.mock('get-port') const getPort = require('get-port') -// const https = require('https') -// const mockScripts = require('@adobe/aio-app-scripts')() let command const mockFindCommandRun = jest.fn() diff --git a/test/commands/app/undeploy.test.js b/test/commands/app/undeploy.test.js index 67b395a6..899f1ef9 100644 --- a/test/commands/app/undeploy.test.js +++ b/test/commands/app/undeploy.test.js @@ -17,12 +17,12 @@ const mockFS = require('fs-extra') // mocks const { stdout } = require('stdout-stderr') -const mockScripts = require('@adobe/aio-app-scripts') +const mockWebLib = require('@adobe/aio-lib-web') const mockRuntimeLib = require('@adobe/aio-lib-runtime') beforeEach(() => { mockRuntimeLib.undeployActions.mockReset() - mockScripts.mockReset('undeployWeb') + mockWebLib.mockReset('undeployWeb') mockFS.existsSync.mockReset() jest.restoreAllMocks() }) @@ -67,7 +67,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) test('undeploy an App with --verbose', async () => { @@ -76,7 +76,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) test('undeploy skip-actions', async () => { @@ -85,7 +85,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) test('undeploy skip-actions verbose', async () => { @@ -94,7 +94,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) test('undeploy skip static', async () => { @@ -103,7 +103,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(0) }) test('undeploy skip static verbose', async () => { @@ -112,7 +112,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(0) }) test('undeploy an app with no backend', async () => { @@ -120,7 +120,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(0) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) expect(command.log).toHaveBeenCalledWith('no manifest file, skipping action undeploy') }) @@ -129,7 +129,7 @@ describe('run', () => { await command.run() expect(command.error).toHaveBeenCalledTimes(0) expect(mockRuntimeLib.undeployActions).toHaveBeenCalledTimes(1) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(0) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(0) expect(command.log).toHaveBeenCalledWith('no web-src, skipping web-src undeploy') }) @@ -145,33 +145,33 @@ describe('run', () => { test('should fail if scripts.undeployWeb fails', async () => { mockFS.existsSync.mockReturnValue(true) const error = new Error('mock failure UI') - mockScripts.mockRejectedValue('undeployWeb', error) + mockWebLib.mockRejectedValue('undeployWeb', error) await command.run() expect(command.error).toHaveBeenCalledWith(error) - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) test('spinner should be called for progress logs on undeployWeb call , with verbose', async () => { mockFS.existsSync.mockReturnValue(true) mockRuntimeLib.undeployActions.mockResolvedValue('ok') - mockScripts.undeployWeb.mockImplementation(async (config, log) => { + mockWebLib.undeployWeb.mockImplementation(async (config, log) => { log('progress log') return 'ok' }) command.argv = ['-v'] await command.run() - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) expect(stdout.output).toEqual(expect.stringContaining('progress log')) }) test('spinner should be called for progress logs on undeployWeb call , without verbose', async () => { mockFS.existsSync.mockReturnValue(true) mockRuntimeLib.undeployActions.mockResolvedValue('ok') - mockScripts.undeployWeb.mockImplementation(async (config, log) => { + mockWebLib.undeployWeb.mockImplementation(async (config, log) => { log('progress log') return 'ok' }) await command.run() - expect(mockScripts.undeployWeb).toHaveBeenCalledTimes(1) + expect(mockWebLib.undeployWeb).toHaveBeenCalledTimes(1) }) }) diff --git a/test/jest.setup.js b/test/jest.setup.js index 5449322e..286a79b9 100644 --- a/test/jest.setup.js +++ b/test/jest.setup.js @@ -85,7 +85,7 @@ jest.mock('fs-extra') // don't wait for user input in tests jest.mock('inquirer') // make sure we mock the app scripts -jest.mock('@adobe/aio-app-scripts') +jest.mock('@adobe/aio-lib-web') // jest.mock('ora') //