Skip to content

Commit

Permalink
fix: update/remove deprecated packages (#62)
Browse files Browse the repository at this point in the history
* fix: use yeoman-environment@4 (ESM)
* remove un-needed test code
  • Loading branch information
shazron authored Jan 23, 2024
1 parent 04d305e commit 08e9329
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
}
},
"parserOptions": {
"ecmaVersion": 2020
"ecmaVersion": "latest"
}
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
"js-yaml": "^3.14.1",
"node-fetch": "^2.6.7",
"ora": "^4.1.1",
"yeoman-environment": "^3.9.1"
"yeoman-environment": "^4.2.1"
},
"devDependencies": {
"@adobe/eslint-config-aio-lib-config": "^2.0.2",
"@types/jest": "^28.1.5",
"acorn": "^7",
"cross-env": "^7.0.3",
"eol": "^0.9.1",
"eslint": "^8.56.0",
"eslint-config-oclif": "^3.1.0",
Expand All @@ -40,11 +41,10 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^29",
"jest-haste-map": "^24.5.0",
"jest": "^29.7.0",
"jest-junit": "^6.0.0",
"jest-resolve": "^24.5.0",
"oclif": "^3.2.0",
"oclif": "^4.3.6",
"stdout-stderr": "^0.1.9",
"typescript": "^5.3.3"
},
Expand All @@ -69,7 +69,7 @@
"scripts": {
"pretest": "npm run lint:check",
"test": "npm run unit-tests",
"unit-tests": "jest --ci",
"unit-tests": "cross-env NODE_OPTIONS=--experimental-vm-modules ./node_modules/jest/bin/jest.js --ci",
"prepack": "oclif manifest && oclif readme --no-aliases",
"postpack": "rm -f oclif.manifest.json",
"version": "oclif readme && git add README.md",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/templates/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const { runScript } = require('../../lib/helper')
const { writeObjectToPackageJson, readPackageJson, getNpmDependency, processNpmPackageSpec, TEMPLATE_PACKAGE_JSON_KEY } = require('../../lib/npm-helper')
const { getTemplateRequiredServiceNames } = require('../../lib/template-helper')
const ora = require('ora')
const yeoman = require('yeoman-environment')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app-templates:templates:install', { provider: 'debug' })
const { Flags } = require('@oclif/core')

Expand Down Expand Up @@ -46,6 +45,8 @@ class InstallCommand extends BaseCommand {
}
aioLogger.debug(`templateName: ${templateName}`)

// eslint-disable-next-line node/no-unsupported-features/es-syntax
const yeoman = await import('yeoman-environment')
const env = yeoman.createEnv()
env.options = { skipInstall: !flags.install }
spinner.info(`Running template ${templateName}`)
Expand Down
8 changes: 4 additions & 4 deletions test/commands/templates/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Ims.context.setCli.mockReset()
Ims.getToken.mockReset()
Ims.getToken.mockResolvedValue('bowling')

// mock generators
jest.mock('yeoman-environment')
const yeoman = require('yeoman-environment')
const yeomanEnvInstantiate = jest.fn()
const yeomanEnvOptionsGet = jest.fn()
const yeomanEnvOptionsSet = jest.fn()
Expand All @@ -55,7 +52,10 @@ Object.defineProperty(createEnvReturnValue, 'options', {
get: yeomanEnvOptionsGet,
set: yeomanEnvOptionsSet
})
yeoman.createEnv.mockReturnValue(createEnvReturnValue)

jest.unstable_mockModule('yeoman-environment', () => ({
createEnv: jest.fn().mockReturnValue(createEnvReturnValue)
}))

jest.mock('my-adobe-template-path', () => ({}), { virtual: true })
jest.mock('my-adobe-package-path', () => ({}), { virtual: true })
Expand Down
2 changes: 1 addition & 1 deletion test/lib/helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ governing permissions and limitations under the License.
const helper = require('../../src/lib/helper')
const execa = require('execa')
const inquirer = require('inquirer')
const { EventEmitter } = require('jest-haste-map')
const EventEmitter = require('node:events')

jest.mock('execa')
jest.mock('inquirer')
Expand Down

0 comments on commit 08e9329

Please sign in to comment.