From b626bd5c4585b66fd92ca0b464303f9fef010d28 Mon Sep 17 00:00:00 2001 From: Florian Pichler Date: Mon, 8 Sep 2025 16:13:28 +0200 Subject: [PATCH 1/2] Install prettier --- .eslintrc.js | 4 +--- .prettierignore | 3 +++ package.json | 5 ++++- pnpm-lock.yaml | 23 +++++++++++++++++++++++ prettier.config.mjs | 9 +++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .prettierignore create mode 100644 prettier.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js index 9ff23a70..3be57908 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,9 +8,7 @@ module.exports = { env: { es6: true }, - extends: [ - 'sane-node' - ], + extends: ['sane-node', 'prettier'], overrides: [ { files: ['bin/**/*.js'], diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..0cb79941 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +test/fixtures/** +pnpm-lock.yaml +CHANGELOG.md diff --git a/package.json b/package.json index e0cd4a3a..d4719b4d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "src" ], "scripts": { - "lint": "eslint . --ext js,json", + "lint": "eslint . --ext js,json && prettier --check .", + "lint:fix": "eslint . --ext js,json --fix && prettier --write .", "start": "node bin/ember-cli-update", "test": "mocha", "test:bin": "mocha --config .mocharc.bin.js", @@ -56,6 +57,7 @@ "chai-string": "^1.5.0", "ember-cli": "3.16.0", "eslint": "^8.16.0", + "eslint-config-prettier": "^10.1.8", "eslint-config-sane": "^1.0.2", "eslint-config-sane-node": "^1.1.1", "eslint-plugin-json-files": "^1.3.0", @@ -66,6 +68,7 @@ "git-fixtures": "^6.0.0", "mocha": "^10.0.0", "mocha-helpers": "^6.2.1", + "prettier": "^3.6.2", "release-it": "^15.5.0", "renovate-config-standard": "2.1.2", "sinon": "^14.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af0fa0c5..ad697278 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,6 +66,9 @@ importers: eslint: specifier: ^8.16.0 version: 8.57.1 + eslint-config-prettier: + specifier: ^10.1.8 + version: 10.1.8(eslint@8.57.1) eslint-config-sane: specifier: ^1.0.2 version: 1.0.2(eslint-plugin-prefer-let@3.0.1)(eslint@8.57.1) @@ -96,6 +99,9 @@ importers: mocha-helpers: specifier: ^6.2.1 version: 6.3.0 + prettier: + specifier: ^3.6.2 + version: 3.6.2 release-it: specifier: ^15.5.0 version: 15.11.0(encoding@0.1.13) @@ -1957,6 +1963,12 @@ packages: engines: {node: '>=4.0'} hasBin: true + eslint-config-prettier@10.1.8: + resolution: {integrity: sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==} + hasBin: true + peerDependencies: + eslint: '>=7.0.0' + eslint-config-sane-node@1.1.1: resolution: {integrity: sha512-scCanxuZrk9dvO+PPE5HwtrCyfovIvS+jIpKLtK81/VE9bRF6r9z5B8xxt1mpJF5brCSiIoAS0vyxnpJ0gxFUw==} peerDependencies: @@ -4254,6 +4266,11 @@ packages: resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} engines: {node: '>=4'} + prettier@3.6.2: + resolution: {integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==} + engines: {node: '>=14'} + hasBin: true + printf@0.6.1: resolution: {integrity: sha512-is0ctgGdPJ5951KulgfzvHGwJtZ5ck8l042vRkV6jrkpBzTmb/lueTqguWHy2JfVA+RY6gFVlaZgUS0j7S/dsw==} engines: {node: '>= 0.9.0'} @@ -7831,6 +7848,10 @@ snapshots: optionalDependencies: source-map: 0.6.1 + eslint-config-prettier@10.1.8(eslint@8.57.1): + dependencies: + eslint: 8.57.1 + eslint-config-sane-node@1.1.1(eslint-config-sane@1.0.2(eslint-plugin-prefer-let@3.0.1)(eslint@8.57.1))(eslint-plugin-json-files@1.5.0(eslint@8.57.1))(eslint-plugin-node@11.1.0(eslint@8.57.1)): dependencies: eslint-config-sane: 1.0.2(eslint-plugin-prefer-let@3.0.1)(eslint@8.57.1) @@ -10621,6 +10642,8 @@ snapshots: prepend-http@2.0.0: {} + prettier@3.6.2: {} + printf@0.6.1: {} proc-log@2.0.1: {} diff --git a/prettier.config.mjs b/prettier.config.mjs new file mode 100644 index 00000000..fc5dd072 --- /dev/null +++ b/prettier.config.mjs @@ -0,0 +1,9 @@ +export default { + singleQuote: true, + trailingComma: 'none', + tabWidth: 2, + semi: true, + printWidth: 80, + bracketSpacing: true, + arrowParens: 'avoid' +}; From 5759ce1c75415aab9358e54b4d24a873161c2b52 Mon Sep 17 00:00:00 2001 From: Florian Pichler Date: Mon, 8 Sep 2025 16:13:34 +0200 Subject: [PATCH 2/2] Apply prettier --- .eslintrc.js | 12 +- .github/ISSUE_TEMPLATE.md | 8 +- .github/workflows/publish.yml | 16 +- .vscode/launch.json | 8 +- README.md | 13 +- RELEASE.md | 16 +- appveyor.yml | 4 +- bin/ember-cli-update.js | 11 +- renovate.json | 8 +- src/args.js | 23 +- src/bootstrap.js | 4 +- src/check-for-blueprint-updates.js | 69 +- src/choose-blueprint-updates.js | 95 +-- src/codemods.js | 18 +- src/compare.js | 26 +- src/get-base-blueprint.js | 6 +- src/get-blueprint-from-args.js | 6 +- src/get-default-blueprint-name-override.js | 14 +- src/get-package-name.js | 5 +- src/get-package-version.js | 8 +- src/get-project-options.js | 9 +- src/get-project-version.js | 11 +- src/get-start-and-end-commands.js | 82 ++- src/get-tag-version.js | 5 +- src/index.js | 40 +- src/init.js | 30 +- src/install-and-generate-blueprint.js | 21 +- src/install.js | 7 +- src/is-default-blueprint.js | 8 +- src/load-default-blueprint-from-disk.js | 5 +- src/load-default-blueprint.js | 7 +- src/load-safe-blueprint-file.js | 37 +- src/normalize-blueprint-args.js | 5 +- src/parse-blueprint-package.js | 12 +- src/reset.js | 46 +- src/resolve-package.js | 6 +- src/save-blueprint-file.js | 55 +- src/save-blueprint.js | 9 +- src/save.js | 2 +- src/stage-blueprint-file.js | 5 +- src/stats.js | 52 +- test/acceptance/ember-cli-update-test.js | 330 +++++----- test/helpers/assertions.js | 6 +- test/helpers/blueprint.js | 6 +- .../check-for-blueprint-updates-test.js | 42 +- test/integration/codemods-test.js | 30 +- test/integration/compare-test.js | 110 ++-- test/integration/download-package-test.js | 40 +- .../get-blueprint-file-path-test.js | 16 +- ...et-default-blueprint-name-override-test.js | 24 +- test/integration/has-yarn-test.js | 8 +- test/integration/index-test.js | 186 +++--- test/integration/init-test.js | 38 +- test/integration/install-test.js | 63 +- test/integration/load-blueprint-file-test.js | 14 +- .../load-default-blueprint-test.js | 64 +- .../load-safe-blueprint-file-test.js | 71 ++- test/integration/load-safe-blueprint-test.js | 13 +- .../overwrite-blueprint-files-test.js | 17 +- .../parse-blueprint-package-test.js | 21 +- test/integration/reset-test.js | 87 +-- test/integration/save-blueprint-file-test.js | 13 +- test/integration/save-test.js | 47 +- test/integration/stats-test.js | 111 ++-- test/unit/find-blueprint-test.js | 10 +- ...et-default-blueprint-name-override-test.js | 98 +-- test/unit/get-package-name-test.js | 8 +- test/unit/get-package-version-test.js | 20 +- test/unit/get-project-options-test.js | 67 +- test/unit/get-project-version-test.js | 24 +- test/unit/get-remote-url-test.js | 8 +- test/unit/get-start-and-end-commands-test.js | 354 ++++++----- .../install-and-generate-blueprint-test.js | 58 +- test/unit/is-default-blueprint-test.js | 50 +- .../load-default-blueprint-from-disk-test.js | 12 +- test/unit/normalize-blueprint-args-test.js | 6 +- test/unit/save-blueprint-test.js | 588 ++++++++++-------- 77 files changed, 1788 insertions(+), 1696 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3be57908..c8419b4b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,18 +17,12 @@ module.exports = { } }, { - files: [ - 'test/**/*-test.js' - ], + files: ['test/**/*-test.js'], env: { mocha: true }, - plugins: [ - 'mocha' - ], - extends: [ - 'plugin:mocha/recommended' - ], + plugins: ['mocha'], + extends: ['plugin:mocha/recommended'], rules: { 'mocha/no-exclusive-tests': 'error', 'mocha/no-empty-description': 'off', diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5dfab42c..6384b7b9 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,9 +1,9 @@ If you are submitting a bug report, please run your command with the debug flag: -* Unix (global): `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember-cli-update ...` -* Windows (global): `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember-cli-update ...` -* Unix (command): `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember update ...` -* Windows (command): `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember update ...` +- Unix (global): `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember-cli-update ...` +- Windows (global): `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember-cli-update ...` +- Unix (command): `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember update ...` +- Windows (command): `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember update ...` and post the console output in the block below: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c2e9f8be..c173bc2d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,12 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: 'https://registry.npmjs.org' + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.vscode/launch.json b/.vscode/launch.json index 220ba640..15fb5b56 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,9 +18,7 @@ "env": { "DEBUG": "ember-cli-update,boilerplate-update,git-diff-apply" }, - "skipFiles": [ - "/**" - ], + "skipFiles": ["/**"], "outputCapture": "std" }, { @@ -28,9 +26,7 @@ "request": "attach", "name": "Attach", "port": 9229, - "skipFiles": [ - "/**" - ] + "skipFiles": ["/**"] } ] } diff --git a/README.md b/README.md index a37c0e3a..a78c6d75 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Update [Ember CLI](https://ember-cli.com/) projects The 2 use cases are: + 1. Updating a project's boilerplate code from an older Ember version to a newer one like 3.4.0 to 3.20.0 for example. These are called base blueprints and there are 3 types officially provided by ember-cli: `app`, `addon`, and `glimmer`. - This is different from the existing `ember init` command. That command tries to reset your project back to a brand new project. It removes all your changes and additions. 2. Updating boilerplate code for a blueprint from an Ember addon from an older version to a newer one. These are called custom blueprints. @@ -315,8 +316,8 @@ And then you're done! You have a freshly updated app (or addon). As noted, you c Need help using `git mergetool`? Here are some starting points: -* https://git-scm.com/docs/git-mergetool -* https://gist.github.com/karenyyng/f19ff75c60f18b4b8149 +- https://git-scm.com/docs/git-mergetool +- https://gist.github.com/karenyyng/f19ff75c60f18b4b8149 If you made a mistake during the update/conflict resolution, run these commands to undo everything and get you back to before the update: @@ -335,9 +336,9 @@ If you run into an error like `error: unrecognized input`, you may need to updat If you are getting an error or unexpected results, running the command with the debug flag: -* Unix (global):   `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember-cli-update` -* Windows (global):   `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember-cli-update` -* Unix (command):   `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember update` -* Windows (command):   `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember update` +- Unix (global):   `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember-cli-update` +- Windows (global):   `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember-cli-update` +- Unix (command):   `DEBUG=ember-cli-update,boilerplate-update,git-diff-apply ember update` +- Windows (command):   `set DEBUG=ember-cli-update,boilerplate-update,git-diff-apply && ember update` will give you more detailed logging. diff --git a/RELEASE.md b/RELEASE.md index aeaa738f..df098f36 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -17,24 +17,24 @@ guiding principle here is that changelogs are for humans, not machines. When reviewing merged PR's the labels to be used are: -* breaking - Used when the PR is considered a breaking change. -* enhancement - Used when the PR adds a new feature or enhancement. -* bug - Used when the PR fixes a bug included in a previous release. -* documentation - Used when the PR adds or updates documentation. -* internal - Used for internal changes that still require a mention in the +- breaking - Used when the PR is considered a breaking change. +- enhancement - Used when the PR adds a new feature or enhancement. +- bug - Used when the PR fixes a bug included in a previous release. +- documentation - Used when the PR adds or updates documentation. +- internal - Used for internal changes that still require a mention in the changelog/release notes. ## Release Once the prep work is completed, the actual release is straight forward: -* First, ensure that you have installed your projects dependencies: +- First, ensure that you have installed your projects dependencies: ```sh npm install ``` -* Second, ensure that you have obtained a +- Second, ensure that you have obtained a [GitHub personal access token][generate-token] with the `repo` scope (no other permissions are needed). Make sure the token is available as the `GITHUB_AUTH` environment variable. @@ -47,7 +47,7 @@ npm install [generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable -* And last (but not least 😁) do your release. +- And last (but not least 😁) do your release. ```sh npx release-it diff --git a/appveyor.yml b/appveyor.yml index ec1fdc88..154856ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ environment: matrix: - - nodejs_version: "14" - DEBUG: "ember-cli-update,boilerplate-update,git-diff-apply" + - nodejs_version: '14' + DEBUG: 'ember-cli-update,boilerplate-update,git-diff-apply' branches: only: diff --git a/bin/ember-cli-update.js b/bin/ember-cli-update.js index e2aa5039..10b5cb87 100755 --- a/bin/ember-cli-update.js +++ b/bin/ember-cli-update.js @@ -1,13 +1,10 @@ #!/usr/bin/env node 'use strict'; -require('yargs') - .commandDir('commands') - .parserConfiguration({ - 'populate--': true, - 'unknown-options-as-args': true - }) - .argv; +require('yargs').commandDir('commands').parserConfiguration({ + 'populate--': true, + 'unknown-options-as-args': true +}).argv; // Displays a message on the terminal if a new version of the package is available. const updateNotifier = require('update-notifier'); diff --git a/renovate.json b/renovate.json index aee685ca..517d21af 100644 --- a/renovate.json +++ b/renovate.json @@ -1,8 +1,4 @@ { - "extends": [ - "standard" - ], - "ignoreDeps": [ - "ember-cli" - ] + "extends": ["standard"], + "ignoreDeps": ["ember-cli"] } diff --git a/src/args.js b/src/args.js index 702382f5..98bed968 100644 --- a/src/args.js +++ b/src/args.js @@ -4,20 +4,24 @@ module.exports = { 'package-name': { alias: ['package', 'p'], type: 'string', - description: 'Provide a package that can contain many blueprints ("@glimmer/blueprint", "git+https://git@github.com/tildeio/libkit.git", "../blueprint")' + description: + 'Provide a package that can contain many blueprints ("@glimmer/blueprint", "git+https://git@github.com/tildeio/libkit.git", "../blueprint")' }, - 'blueprint': { + blueprint: { alias: ['b'], type: 'string', - description: 'Provide a custom blueprint for use in the update ("@glimmer/blueprint", "git+https://git@github.com/tildeio/libkit.git", "../blueprint")' + description: + 'Provide a custom blueprint for use in the update ("@glimmer/blueprint", "git+https://git@github.com/tildeio/libkit.git", "../blueprint")' }, - 'from': { + from: { type: 'string', - description: 'Use a starting version that is different than what is in your package.json ("2.9.1")' + description: + 'Use a starting version that is different than what is in your package.json ("2.9.1")' }, - 'to': { + to: { type: 'string', - description: 'Update to a version that isn\'t latest ("2.14.1", "~2.15", "latest", "beta")' + description: + 'Update to a version that isn\'t latest ("2.14.1", "~2.15", "latest", "beta")' }, 'resolve-conflicts': { type: 'boolean', @@ -31,13 +35,14 @@ module.exports = { }, 'codemods-source': { type: 'string', - description: 'Supply your own codemods manifest via URL ("ember-app-codemods-manifest@*", "git+https://github.com/ember-cli/ember-app-codemods-manifest.git#semver:*")' + description: + 'Supply your own codemods manifest via URL ("ember-app-codemods-manifest@*", "git+https://github.com/ember-cli/ember-app-codemods-manifest.git#semver:*")' }, 'codemods-json': { type: 'string', description: 'Supply your own codemods manifest via JSON (`{ /* json */ }`)' }, - 'reset': { + reset: { type: 'boolean', default: false, description: 'Reset your code to the default blueprint at the new version' diff --git a/src/bootstrap.js b/src/bootstrap.js index 4e947094..2339aec1 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -4,9 +4,7 @@ const saveBlueprint = require('./save-blueprint'); const loadDefaultBlueprintFromDisk = require('./load-default-blueprint-from-disk'); const getBlueprintFilePath = require('./get-blueprint-file-path'); -module.exports = async function bootstrap({ - cwd = process.cwd() -} = {}) { +module.exports = async function bootstrap({ cwd = process.cwd() } = {}) { let emberCliUpdateJsonPath = await getBlueprintFilePath(cwd); let blueprint = await loadDefaultBlueprintFromDisk({ cwd }); diff --git a/src/check-for-blueprint-updates.js b/src/check-for-blueprint-updates.js index 354154d3..3f2affb3 100644 --- a/src/check-for-blueprint-updates.js +++ b/src/check-for-blueprint-updates.js @@ -6,39 +6,42 @@ const getTagVersion = require('boilerplate-update/src/get-tag-version'); const { defaultTo } = require('./constants'); const utils = require('./utils'); -async function checkForBlueprintUpdates({ - cwd, - blueprints -}) { - return await Promise.all(blueprints.map(async blueprint => { - let currentVersion = blueprint.version; - let latestVersion; - - if (!blueprint.location) { - let versions = await utils.getVersions(blueprint.packageName); - - latestVersion = await getTagVersion({ - range: defaultTo, - versions, - packageName: blueprint.packageName - }); - } else { - let parsedPackage = await parseBlueprintPackage({ - cwd, - packageName: blueprint.location || blueprint.packageName - }); - - let downloadedPackage = await downloadPackage(blueprint.packageName, parsedPackage.url, defaultTo); - - latestVersion = downloadedPackage.version; - } - - return { - blueprint, - latestVersion, - isUpToDate: currentVersion === latestVersion - }; - })); +async function checkForBlueprintUpdates({ cwd, blueprints }) { + return await Promise.all( + blueprints.map(async blueprint => { + let currentVersion = blueprint.version; + let latestVersion; + + if (!blueprint.location) { + let versions = await utils.getVersions(blueprint.packageName); + + latestVersion = await getTagVersion({ + range: defaultTo, + versions, + packageName: blueprint.packageName + }); + } else { + let parsedPackage = await parseBlueprintPackage({ + cwd, + packageName: blueprint.location || blueprint.packageName + }); + + let downloadedPackage = await downloadPackage( + blueprint.packageName, + parsedPackage.url, + defaultTo + ); + + latestVersion = downloadedPackage.version; + } + + return { + blueprint, + latestVersion, + isUpToDate: currentVersion === latestVersion + }; + }) + ); } module.exports = checkForBlueprintUpdates; diff --git a/src/choose-blueprint-updates.js b/src/choose-blueprint-updates.js index 42b1d009..5872d297 100644 --- a/src/choose-blueprint-updates.js +++ b/src/choose-blueprint-updates.js @@ -12,23 +12,19 @@ const { defaultTo } = require('./constants'); * @param {string} latestVersion - Latest version for the blueprint * @returns {string} */ -function formatBlueprintLine({ - blueprint, - latestVersion -}) { +function formatBlueprintLine({ blueprint, latestVersion }) { return `${blueprint.name}, current: ${blueprint.version}, latest: ${latestVersion}`; } -async function chooseBlueprint({ - choicesByName, - message -}) { - let answer = await inquirer.prompt([{ - type: 'list', - message, - name: 'blueprint', - choices: Object.values(choicesByName).map(({ choice }) => choice) - }]); +async function chooseBlueprint({ choicesByName, message }) { + let answer = await inquirer.prompt([ + { + type: 'list', + message, + name: 'blueprint', + choices: Object.values(choicesByName).map(({ choice }) => choice) + } + ]); return choicesByName[answer.blueprint]; } @@ -78,17 +74,21 @@ async function chooseBlueprintUpdates({ message = 'Which blueprint would you like to run codemods for?'; } - existingBlueprint = (await chooseBlueprint({ - choicesByName, - message - })).blueprint; + existingBlueprint = ( + await chooseBlueprint({ + choicesByName, + message + }) + ).blueprint; } else { let blueprintUpdates = await checkForBlueprintUpdates({ cwd, blueprints }); - areAllUpToDate = blueprintUpdates.every(blueprintUpdate => blueprintUpdate.isUpToDate); + areAllUpToDate = blueprintUpdates.every( + blueprintUpdate => blueprintUpdate.isUpToDate + ); if (areAllUpToDate) { // eslint-disable-next-line no-console @@ -97,21 +97,25 @@ async function chooseBlueprintUpdates({ All blueprints are up-to-date!`); } else { - let choicesByName = blueprintUpdates.reduce((choices, blueprintUpdate) => { - let name = formatBlueprintLine(blueprintUpdate); - choices[name] = { - blueprintUpdate, - choice: { - name, - disabled: blueprintUpdate.isUpToDate - } - }; - return choices; - }, {}); + let choicesByName = blueprintUpdates.reduce( + (choices, blueprintUpdate) => { + let name = formatBlueprintLine(blueprintUpdate); + choices[name] = { + blueprintUpdate, + choice: { + name, + disabled: blueprintUpdate.isUpToDate + } + }; + return choices; + }, + {} + ); let { blueprintUpdate } = await chooseBlueprint({ choicesByName, - message: 'Blueprint updates have been found. Which one would you like to update?' + message: + 'Blueprint updates have been found. Which one would you like to update?' }); existingBlueprint = blueprintUpdate.blueprint; @@ -119,24 +123,25 @@ All blueprints are up-to-date!`); if (typeof to !== 'string') { let latestVersion = `${blueprintUpdate.latestVersion} (latest)`; - let answer = await inquirer.prompt([{ - type: 'list', - message: 'Do you want the latest version?', - name: 'choice', - choices: [ - latestVersion, - 'SemVer string' - ] - }]); + let answer = await inquirer.prompt([ + { + type: 'list', + message: 'Do you want the latest version?', + name: 'choice', + choices: [latestVersion, 'SemVer string'] + } + ]); if (answer.choice === latestVersion) { to = defaultTo; } else { - answer = await inquirer.prompt([{ - type: 'input', - message: 'What version?', - name: 'semver' - }]); + answer = await inquirer.prompt([ + { + type: 'input', + message: 'What version?', + name: 'semver' + } + ]); to = answer.semver; } diff --git a/src/codemods.js b/src/codemods.js index bdbfd083..1364561c 100644 --- a/src/codemods.js +++ b/src/codemods.js @@ -21,14 +21,14 @@ module.exports = async function codemods({ if (!sourceJson) { let emberCliUpdateJsonPath = await getBlueprintFilePath(cwd); - let emberCliUpdateJson = await loadSafeBlueprintFile(emberCliUpdateJsonPath); + let emberCliUpdateJson = await loadSafeBlueprintFile( + emberCliUpdateJsonPath + ); let { blueprints } = emberCliUpdateJson; if (_blueprint) { - let { - existingBlueprint - } = await getBlueprintFromArgs({ + let { existingBlueprint } = await getBlueprintFromArgs({ cwd, emberCliUpdateJson, blueprint: _blueprint @@ -36,9 +36,7 @@ module.exports = async function codemods({ blueprint = existingBlueprint; } else if (blueprints.length) { - let { - blueprint: _blueprint - } = await chooseBlueprintUpdates({ + let { blueprint: _blueprint } = await chooseBlueprintUpdates({ cwd, emberCliUpdateJson, codemods: true @@ -58,11 +56,9 @@ module.exports = async function codemods({ } } - let { - promise - } = await boilerplateUpdate({ + let { promise } = await boilerplateUpdate({ cwd, - projectOptions: async({ packageJson }) => { + projectOptions: async ({ packageJson }) => { if (!blueprint) { return []; } diff --git a/src/compare.js b/src/compare.js index 004dcbd4..3472f29c 100644 --- a/src/compare.js +++ b/src/compare.js @@ -29,24 +29,20 @@ module.exports = async function compare({ let packageInfo; if (_blueprint) { - let { - packageInfo: _packageInfo, - existingBlueprint - } = await getBlueprintFromArgs({ - cwd, - emberCliUpdateJson, - packageName, - blueprint: _blueprint, - to - }); + let { packageInfo: _packageInfo, existingBlueprint } = + await getBlueprintFromArgs({ + cwd, + emberCliUpdateJson, + packageName, + blueprint: _blueprint, + to + }); packageInfo = _packageInfo; blueprint = existingBlueprint; } else { if (blueprints.length) { - let { - blueprint: _blueprint - } = await chooseBlueprintUpdates({ + let { blueprint: _blueprint } = await chooseBlueprintUpdates({ cwd, emberCliUpdateJson, compare: true @@ -70,9 +66,7 @@ module.exports = async function compare({ }); } - let { - promise - } = await boilerplateUpdate({ + let { promise } = await boilerplateUpdate({ cwd, startVersion: blueprint.version, endVersion: packageInfo.version, diff --git a/src/get-base-blueprint.js b/src/get-base-blueprint.js index 70bf2f00..d2951fd0 100644 --- a/src/get-base-blueprint.js +++ b/src/get-base-blueprint.js @@ -15,11 +15,7 @@ const isDefaultBlueprint = require('./is-default-blueprint'); * @param blueprint - Figure out if this is a base blueprint * @returns {Promise<*>} */ -async function getBaseBlueprint({ - cwd, - blueprints, - blueprint -}) { +async function getBaseBlueprint({ cwd, blueprints, blueprint }) { let baseBlueprint; let isCustomBlueprint = !isDefaultBlueprint(blueprint); diff --git a/src/get-blueprint-from-args.js b/src/get-blueprint-from-args.js index 306859a9..078de89b 100644 --- a/src/get-blueprint-from-args.js +++ b/src/get-blueprint-from-args.js @@ -38,7 +38,11 @@ async function getBlueprintFromArgs({ blueprintName = packageName; } - let existingBlueprint = findBlueprint(emberCliUpdateJson, packageName, blueprintName); + let existingBlueprint = findBlueprint( + emberCliUpdateJson, + packageName, + blueprintName + ); if (!existingBlueprint) { throw `blueprint "${blueprint}" was not found`; } diff --git a/src/get-default-blueprint-name-override.js b/src/get-default-blueprint-name-override.js index c3af2196..799e62c4 100644 --- a/src/get-default-blueprint-name-override.js +++ b/src/get-default-blueprint-name-override.js @@ -12,15 +12,23 @@ const pacote = require('pacote'); * @param {string} cwd - Default to the process's CWD. Parent functions can override * @returns {Promise>} */ -module.exports = async function getBlueprintNameOverride(packageNameOrPath, cwd = process.cwd()) { - let localPackageJsonPath = path.join(path.resolve(cwd, packageNameOrPath), 'package.json'); +module.exports = async function getBlueprintNameOverride( + packageNameOrPath, + cwd = process.cwd() +) { + let localPackageJsonPath = path.join( + path.resolve(cwd, packageNameOrPath), + 'package.json' + ); let packageJson; if (await fs.pathExists(localPackageJsonPath)) { packageJson = JSON.parse(await fs.readFile(localPackageJsonPath)); } else { try { - packageJson = await pacote.manifest(packageNameOrPath, { fullMetadata: true }); + packageJson = await pacote.manifest(packageNameOrPath, { + fullMetadata: true + }); } catch (err) { if (err.statusCode !== 404) { throw err; diff --git a/src/get-package-name.js b/src/get-package-name.js index 7b7e0d61..eaf3a275 100644 --- a/src/get-package-name.js +++ b/src/get-package-name.js @@ -1,9 +1,6 @@ 'use strict'; -const { - defaultPackageName, - glimmerPackageName -} = require('./constants'); +const { defaultPackageName, glimmerPackageName } = require('./constants'); module.exports = function getPackageName(projectOptions) { let packageName; diff --git a/src/get-package-version.js b/src/get-package-version.js index 8de86559..f08da5ed 100644 --- a/src/get-package-version.js +++ b/src/get-package-version.js @@ -1,9 +1,9 @@ 'use strict'; -module.exports = function getPackageVersion({ - dependencies, - devDependencies -}, packageName) { +module.exports = function getPackageVersion( + { dependencies, devDependencies }, + packageName +) { let allDeps = Object.assign({}, dependencies, devDependencies); let packageVersion = allDeps[packageName]; diff --git a/src/get-project-options.js b/src/get-project-options.js index 9ebda8fc..6b694f43 100644 --- a/src/get-project-options.js +++ b/src/get-project-options.js @@ -42,11 +42,10 @@ function getProjectType(checkForDep, keywords) { * @param {object} blueprint - Expected to contain `packageName` and `name` * @returns {Promise<[string]|string[]>} - Array of strings containing keywords */ -module.exports = async function getProjectOptions({ - keywords, - dependencies, - devDependencies -}, blueprint) { +module.exports = async function getProjectOptions( + { keywords, dependencies, devDependencies }, + blueprint +) { if (blueprint && !isDefaultBlueprint(blueprint)) { return ['blueprint']; } diff --git a/src/get-project-version.js b/src/get-project-version.js index 71610282..38e7dae4 100644 --- a/src/get-project-version.js +++ b/src/get-project-version.js @@ -13,11 +13,18 @@ const glimmerVersionCutoff = '0.6.3'; * @param {object} projectOptions - Glimmer projects are a special case * @returns {string} */ -module.exports = function getProjectVersion(packageVersion, versions, projectOptions) { +module.exports = function getProjectVersion( + packageVersion, + versions, + projectOptions +) { // _getProjectVersion gets the minimum version that satisfies the given packageVersion string let projectVersion = _getProjectVersion(packageVersion, versions); - if (projectOptions.includes('glimmer') && semver.lt(projectVersion, glimmerVersionCutoff)) { + if ( + projectOptions.includes('glimmer') && + semver.lt(projectVersion, glimmerVersionCutoff) + ) { throw `This Glimmer app was generated using a blueprint version older than v${glimmerVersionCutoff}, and therefore the version cannot be determined. Please use the "--from" option to indicate your starting version.`; } diff --git a/src/get-start-and-end-commands.js b/src/get-start-and-end-commands.js index 8b8c4f32..7d79ce03 100644 --- a/src/get-start-and-end-commands.js +++ b/src/get-start-and-end-commands.js @@ -40,7 +40,9 @@ module.exports = function getStartAndEndCommands({ } if (baseBlueprint && !baseBlueprint.isBaseBlueprint) { - throw new Error('The intended base blueprint is not actually a base blueprint.'); + throw new Error( + 'The intended base blueprint is not actually a base blueprint.' + ); } if (endBlueprint.isBaseBlueprint && baseBlueprint) { @@ -48,14 +50,19 @@ module.exports = function getStartAndEndCommands({ } let isCustomBlueprint = !isDefaultBlueprint(endBlueprint); - let isGlimmer = endBlueprint.packageName === glimmerPackageName && endBlueprint.name === glimmerPackageName; + let isGlimmer = + endBlueprint.packageName === glimmerPackageName && + endBlueprint.name === glimmerPackageName; let startRange; let endRange; if (!isCustomBlueprint && !isGlimmer) { startRange = startBlueprint && startBlueprint.version; endRange = endBlueprint.version; - } else if (!endBlueprint.isBaseBlueprint && isDefaultBlueprint(baseBlueprint)) { + } else if ( + !endBlueprint.isBaseBlueprint && + isDefaultBlueprint(baseBlueprint) + ) { startRange = endRange = baseBlueprint.version; } else { // first version that supports blueprints with versions @@ -100,21 +107,16 @@ async function isDefaultAddonBlueprint(blueprint) { keywords = await npm.json('v', blueprint.packageName, 'keywords'); } - isDefaultAddonBlueprint = !(keywords && keywords.includes('ember-blueprint')); + isDefaultAddonBlueprint = !( + keywords && keywords.includes('ember-blueprint') + ); } return isDefaultAddonBlueprint; } -function getArgs({ - projectName, - directoryName, - blueprint -}) { - let args = [ - 'new', - projectName - ]; +function getArgs({ projectName, directoryName, blueprint }) { + let args = ['new', projectName]; if (directoryName !== projectName) { args.push(`-dir=${directoryName}`); @@ -130,7 +132,9 @@ function getArgs({ _blueprint = blueprint.path; } else { let isCustomBlueprint = !isDefaultBlueprint(blueprint); - let isGlimmer = blueprint.packageName === glimmerPackageName && blueprint.name === glimmerPackageName; + let isGlimmer = + blueprint.packageName === glimmerPackageName && + blueprint.name === glimmerPackageName; if (isCustomBlueprint || isGlimmer) { _blueprint = `${blueprint.packageName}@${blueprint.version}`; @@ -139,13 +143,7 @@ function getArgs({ } } - return [ - ...args, - '--skip-npm', - '-b', - _blueprint, - ...blueprint.options - ]; + return [...args, '--skip-npm', '-b', _blueprint, ...blueprint.options]; } module.exports.spawn = function spawn(command, args, options) { @@ -165,24 +163,19 @@ module.exports.npx = function npx(args, options) { return utils.npx(args.join(' '), options); }; -function runEmberLocally({ - packageRoot, - cwd, - args -}) { - return module.exports.spawn('node', [ - path.join(packageRoot, 'bin/ember'), - ...args - ], { cwd }); +function runEmberLocally({ packageRoot, cwd, args }) { + return module.exports.spawn( + 'node', + [path.join(packageRoot, 'bin/ember'), ...args], + { cwd } + ); } -function runEmberRemotely({ - cwd, - blueprint, - args -}) { +function runEmberRemotely({ cwd, blueprint, args }) { let isCustomBlueprint = !isDefaultBlueprint(blueprint); - let isGlimmer = blueprint.packageName === glimmerPackageName && blueprint.name === glimmerPackageName; + let isGlimmer = + blueprint.packageName === glimmerPackageName && + blueprint.name === glimmerPackageName; if (isCustomBlueprint || isGlimmer) { args = ['ember-cli@latest', ...args]; @@ -197,11 +190,7 @@ function runEmberRemotely({ function createProject(runEmber) { return ({ packageRoot, - options: { - projectName, - baseBlueprint, - blueprint - } + options: { projectName, baseBlueprint, blueprint } }) => { return async function createProject(cwd) { if (!blueprint) { @@ -305,10 +294,8 @@ module.exports.installAddonBlueprint = async function installAddonBlueprint({ await fs.remove(path.join(projectRoot, 'package-lock.json')); }; -async function appendNodeModulesIgnore({ - projectRoot -}) { - if (!await fs.pathExists(path.join(projectRoot, 'node_modules'))) { +async function appendNodeModulesIgnore({ projectRoot }) { + if (!(await fs.pathExists(path.join(projectRoot, 'node_modules')))) { return; } @@ -320,7 +307,10 @@ async function appendNodeModulesIgnore({ isIgnoringNodeModules = /^\/?node_modules\/?$/m.test(gitignore); } catch (err) {} if (!isIgnoringNodeModules) { - await fs.writeFile(path.join(projectRoot, '.gitignore'), `${gitignore}${nodeModulesIgnore}`); + await fs.writeFile( + path.join(projectRoot, '.gitignore'), + `${gitignore}${nodeModulesIgnore}` + ); } } diff --git a/src/get-tag-version.js b/src/get-tag-version.js index 73c5b41c..eab3cb64 100644 --- a/src/get-tag-version.js +++ b/src/get-tag-version.js @@ -8,10 +8,7 @@ module.exports = function getTagVersion(versions, packageName) { range, versions, packageName, - distTags: [ - 'latest', - 'beta' - ] + distTags: ['latest', 'beta'] }); }; }; diff --git a/src/index.js b/src/index.js index 47222dce..9bd08126 100644 --- a/src/index.js +++ b/src/index.js @@ -39,10 +39,7 @@ async function _resolvePackage(blueprint, url, range) { return; } - let { - version, - path - } = await resolvePackage({ + let { version, path } = await resolvePackage({ name: blueprint.packageName, url, range @@ -89,7 +86,11 @@ module.exports = async function emberCliUpdate({ packageName = parsedPackage.name; if (!packageName) { - let downloadedPackage = await downloadPackage(null, packageUrl, defaultTo); + let downloadedPackage = await downloadPackage( + null, + packageUrl, + defaultTo + ); packageName = downloadedPackage.name; } let blueprintName; @@ -99,7 +100,11 @@ module.exports = async function emberCliUpdate({ blueprintName = packageName; } - let existingBlueprint = findBlueprint(emberCliUpdateJson, packageName, blueprintName); + let existingBlueprint = findBlueprint( + emberCliUpdateJson, + packageName, + blueprintName + ); if (existingBlueprint) { blueprint = existingBlueprint; } else { @@ -122,7 +127,9 @@ module.exports = async function emberCliUpdate({ } if (!blueprint.version) { - throw new Error('A custom blueprint cannot detect --from. You must supply it.'); + throw new Error( + 'A custom blueprint cannot detect --from. You must supply it.' + ); } } else if (blueprints.length) { let { @@ -179,21 +186,18 @@ module.exports = async function emberCliUpdate({ if (resolveConflicts) { // eslint-disable-next-line no-console - console.warn('`--resolve-conflicts` is deprecated. Please run `git mergetool` manually.'); + console.warn( + '`--resolve-conflicts` is deprecated. Please run `git mergetool` manually.' + ); } let endBlueprint; - let { - promise, - resolveConflictsProcess - } = await boilerplateUpdate({ + let { promise, resolveConflictsProcess } = await boilerplateUpdate({ cwd, - projectOptions: ({ packageJson }) => getProjectOptions(packageJson, blueprint), - mergeOptions: async function mergeOptions({ - packageJson, - projectOptions - }) { + projectOptions: ({ packageJson }) => + getProjectOptions(packageJson, blueprint), + mergeOptions: async function mergeOptions({ packageJson, projectOptions }) { let startBlueprint = { ...blueprint }; endBlueprint = { ...blueprint }; delete endBlueprint.version; @@ -230,7 +234,7 @@ module.exports = async function emberCliUpdate({ }); return { - promise: (async() => { + promise: (async () => { let result = await promise; await saveBlueprint({ diff --git a/src/init.js b/src/init.js index 83266c52..8bb0eceb 100644 --- a/src/init.js +++ b/src/init.js @@ -84,7 +84,11 @@ module.exports = async function init({ let blueprint; - let existingBlueprint = findBlueprint(emberCliUpdateJson, packageName, blueprintName); + let existingBlueprint = findBlueprint( + emberCliUpdateJson, + packageName, + blueprintName + ); if (existingBlueprint) { blueprint = existingBlueprint; } else { @@ -129,30 +133,28 @@ module.exports = async function init({ if (resolveConflicts) { // eslint-disable-next-line no-console - console.warn('`--resolve-conflicts` is deprecated. Please run `git mergetool` manually.'); + console.warn( + '`--resolve-conflicts` is deprecated. Please run `git mergetool` manually.' + ); } - let { - promise, - resolveConflictsProcess - } = await boilerplateUpdate({ + let { promise, resolveConflictsProcess } = await boilerplateUpdate({ cwd, endVersion: blueprint.version, resolveConflicts, init, createCustomDiff: true, - customDiffOptions: ({ - packageJson - }) => getStartAndEndCommands({ - packageJson, - baseBlueprint, - endBlueprint: blueprint - }), + customDiffOptions: ({ packageJson }) => + getStartAndEndCommands({ + packageJson, + baseBlueprint, + endBlueprint: blueprint + }), ignoredFiles: [await getBlueprintRelativeFilePath(cwd)] }); return { - promise: (async() => { + promise: (async () => { let result = await promise; await saveBlueprint({ diff --git a/src/install-and-generate-blueprint.js b/src/install-and-generate-blueprint.js index 40c7064b..5ff9fd56 100644 --- a/src/install-and-generate-blueprint.js +++ b/src/install-and-generate-blueprint.js @@ -4,10 +4,7 @@ const execa = require('execa'); const { spawn } = require('./run'); const debug = require('./debug'); -function ember(args, { - cwd, - stdin = 'inherit' -}) { +function ember(args, { cwd, stdin = 'inherit' }) { debug(`ember ${args.join(' ')}`); let ps = execa('ember', args, { @@ -87,9 +84,21 @@ async function installAndGenerateBlueprint({ packageName ); - await module.exports.spawn(packageManager, [INSTALL_COMMAND[packageManager], '--save-dev', resolvedPackageName], { cwd }); + await module.exports.spawn( + packageManager, + [INSTALL_COMMAND[packageManager], '--save-dev', resolvedPackageName], + { + cwd + } + ); - let generateProcess = module.exports.ember(['g', blueprintName, ...blueprintOptions], { cwd, stdin }); + let generateProcess = module.exports.ember( + ['g', blueprintName, ...blueprintOptions], + { + cwd, + stdin + } + ); return { ps: generateProcess diff --git a/src/install.js b/src/install.js index bf8e3f06..1d828d15 100644 --- a/src/install.js +++ b/src/install.js @@ -42,7 +42,10 @@ module.exports = async function install({ let blueprintName = _blueprintName; if (!blueprintName) { - let defaultBlueprintOverride = await getBlueprintNameOverride(path || packageName, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + path || packageName, + cwd + ); blueprintName = defaultBlueprintOverride || packageName; } @@ -71,7 +74,7 @@ module.exports = async function install({ version }); - if (!await loadBlueprintFile(emberCliUpdateJsonPath)) { + if (!(await loadBlueprintFile(emberCliUpdateJsonPath))) { await bootstrap({ cwd }); } diff --git a/src/is-default-blueprint.js b/src/is-default-blueprint.js index 525c104f..3744bd6c 100644 --- a/src/is-default-blueprint.js +++ b/src/is-default-blueprint.js @@ -18,10 +18,10 @@ function isDefaultBlueprint({ packageName, name }) { if (packageName === glimmerPackageName && name === glimmerPackageName) { return true; } - return packageName === defaultPackageName && [ - defaultAppBlueprintName, - defaultAddonBlueprintName - ].includes(name); + return ( + packageName === defaultPackageName && + [defaultAppBlueprintName, defaultAddonBlueprintName].includes(name) + ); } module.exports = isDefaultBlueprint; diff --git a/src/load-default-blueprint-from-disk.js b/src/load-default-blueprint-from-disk.js index 2f11a08c..ee8dab19 100644 --- a/src/load-default-blueprint-from-disk.js +++ b/src/load-default-blueprint-from-disk.js @@ -16,10 +16,7 @@ const utils = require('./utils'); * @param {string} version - Optional. if not pass will use the one specified in package json * @returns {Promise<*|{}>} */ -async function loadDefaultBlueprintFromDisk({ - cwd, - version -}) { +async function loadDefaultBlueprintFromDisk({ cwd, version }) { let packageJson; try { packageJson = utils.require(path.join(cwd, 'package')); diff --git a/src/load-default-blueprint.js b/src/load-default-blueprint.js index 19a00f1e..4f4ded6b 100644 --- a/src/load-default-blueprint.js +++ b/src/load-default-blueprint.js @@ -29,7 +29,10 @@ function loadDefaultBlueprint(projectOptions = [], version) { if (projectOptions.includes('yarn')) { options.push('--yarn'); } - if (!projectOptions.includes('welcome') || projectOptions.includes('addon')) { + if ( + !projectOptions.includes('welcome') || + projectOptions.includes('addon') + ) { // Why do addons always have --no-welcome? options.push('--no-welcome'); } @@ -40,7 +43,7 @@ function loadDefaultBlueprint(projectOptions = [], version) { name, version, outputRepo: getRemoteUrl(projectOptions), - ...codemodsSource ? { codemodsSource } : {}, + ...(codemodsSource ? { codemodsSource } : {}), options, isBaseBlueprint: true }); diff --git a/src/load-safe-blueprint-file.js b/src/load-safe-blueprint-file.js index 62346a39..425691e5 100644 --- a/src/load-safe-blueprint-file.js +++ b/src/load-safe-blueprint-file.js @@ -31,11 +31,17 @@ async function loadSafeBlueprintFile(emberCliUpdateJsonPath) { if ('schemaVersion' in emberCliUpdateJson) { if (emberCliUpdateJson.schemaVersion === 0) { - // if (semver.lt(emberCliUpdateJson.schemaVersion, currentSchemaVersion)) { + // if (semver.lt(emberCliUpdateJson.schemaVersion, currentSchemaVersion)) { // eslint-disable-next-line no-console - console.warn(`Updating schemaVersion from ${emberCliUpdateJson.schemaVersion} to ${currentSchemaVersion}.`); - } else if (semver.gt(emberCliUpdateJson.schemaVersion, currentSchemaVersion)) { - throw new Error(`schemaVersion ${emberCliUpdateJson.schemaVersion} is unexpectedly newer than the current ${currentSchemaVersion}.`); + console.warn( + `Updating schemaVersion from ${emberCliUpdateJson.schemaVersion} to ${currentSchemaVersion}.` + ); + } else if ( + semver.gt(emberCliUpdateJson.schemaVersion, currentSchemaVersion) + ) { + throw new Error( + `schemaVersion ${emberCliUpdateJson.schemaVersion} is unexpectedly newer than the current ${currentSchemaVersion}.` + ); } } @@ -45,19 +51,22 @@ async function loadSafeBlueprintFile(emberCliUpdateJsonPath) { emberCliUpdateJson.packages = []; } - emberCliUpdateJson.blueprints = emberCliUpdateJson.packages.reduce((blueprints, _package) => { - for (let blueprint of _package.blueprints) { - blueprint.packageName = _package.name; - blueprint.location = _package.location; - blueprint.version = _package.version; + emberCliUpdateJson.blueprints = emberCliUpdateJson.packages.reduce( + (blueprints, _package) => { + for (let blueprint of _package.blueprints) { + blueprint.packageName = _package.name; + blueprint.location = _package.location; + blueprint.version = _package.version; - blueprint = loadSafeBlueprint(blueprint); + blueprint = loadSafeBlueprint(blueprint); - blueprints.push(blueprint); - } + blueprints.push(blueprint); + } - return blueprints; - }, []); + return blueprints; + }, + [] + ); delete emberCliUpdateJson.packages; diff --git a/src/normalize-blueprint-args.js b/src/normalize-blueprint-args.js index f6ff86c0..48013c47 100644 --- a/src/normalize-blueprint-args.js +++ b/src/normalize-blueprint-args.js @@ -7,10 +7,7 @@ * @param {string} blueprintName - Name of blueprint * @returns {{blueprintName, packageName}} */ -function normalizeBlueprintArgs({ - packageName, - blueprintName -}) { +function normalizeBlueprintArgs({ packageName, blueprintName }) { if (!packageName) { packageName = blueprintName; } diff --git a/src/parse-blueprint-package.js b/src/parse-blueprint-package.js index 606ab80d..1dbbdbf8 100644 --- a/src/parse-blueprint-package.js +++ b/src/parse-blueprint-package.js @@ -5,7 +5,7 @@ const { URL } = require('url'); const fs = require('fs-extra'); function toPosixAbsolutePath(path) { - let posixPath = path.replace(/\\/g, '/').replace(/^(.+):/, function() { + let posixPath = path.replace(/\\/g, '/').replace(/^(.+):/, function () { return arguments[1].toLowerCase(); }); if (!posixPath.startsWith('/')) { @@ -21,10 +21,7 @@ function toPosixAbsolutePath(path) { * @param {string} packageName - Can be local path (absolute or relative) or url * @returns {Promise<{name: string, location: string, url: string}>} */ -async function parseBlueprintPackage({ - cwd = '.', - packageName -}) { +async function parseBlueprintPackage({ cwd = '.', packageName }) { let name; let location; let url; @@ -32,7 +29,10 @@ async function parseBlueprintPackage({ if (packageName.startsWith('.')) { blueprintPath = path.resolve(cwd, packageName); - } else if (path.isAbsolute(packageName) && await fs.pathExists(packageName)) { + } else if ( + path.isAbsolute(packageName) && + (await fs.pathExists(packageName)) + ) { blueprintPath = packageName; } diff --git a/src/reset.js b/src/reset.js index e8c7504f..1c1d0a34 100644 --- a/src/reset.js +++ b/src/reset.js @@ -26,7 +26,9 @@ module.exports = async function reset({ // We must rely on a lookup before the run. let emberCliUpdateJsonPath = await getBlueprintFilePath(cwd); - let emberCliUpdateJson = await loadSafeBlueprintFile(emberCliUpdateJsonPath); + let emberCliUpdateJson = await loadSafeBlueprintFile( + emberCliUpdateJsonPath + ); let { blueprints } = emberCliUpdateJson; @@ -34,24 +36,20 @@ module.exports = async function reset({ let packageInfo; if (_blueprint) { - let { - packageInfo: _packageInfo, - existingBlueprint - } = await getBlueprintFromArgs({ - cwd, - emberCliUpdateJson, - packageName, - blueprint: _blueprint, - to - }); + let { packageInfo: _packageInfo, existingBlueprint } = + await getBlueprintFromArgs({ + cwd, + emberCliUpdateJson, + packageName, + blueprint: _blueprint, + to + }); packageInfo = _packageInfo; blueprint = existingBlueprint; } else { if (blueprints.length) { - let { - blueprint: _blueprint - } = await chooseBlueprintUpdates({ + let { blueprint: _blueprint } = await chooseBlueprintUpdates({ cwd, emberCliUpdateJson, reset: true @@ -87,26 +85,22 @@ module.exports = async function reset({ }); } - let { - promise, - resolveConflictsProcess - } = await boilerplateUpdate({ + let { promise, resolveConflictsProcess } = await boilerplateUpdate({ cwd, endVersion: blueprint.version, reset: true, createCustomDiff: true, - customDiffOptions: ({ - packageJson - }) => getStartAndEndCommands({ - packageJson, - baseBlueprint, - endBlueprint: blueprint - }), + customDiffOptions: ({ packageJson }) => + getStartAndEndCommands({ + packageJson, + baseBlueprint, + endBlueprint: blueprint + }), ignoredFiles: [await getBlueprintRelativeFilePath(cwd)] }); return { - promise: (async() => { + promise: (async () => { let result = await promise; await saveBlueprint({ diff --git a/src/resolve-package.js b/src/resolve-package.js index 06cc4e4d..f9e2b7f3 100644 --- a/src/resolve-package.js +++ b/src/resolve-package.js @@ -12,11 +12,7 @@ const _getTagVersion = require('./get-tag-version'); * @param {string} range - Version string such as ^1.2.3 or 2.0.0 * @returns {Promise<{path, name, version: *, defaultBlueprintOverride}>} */ -async function resolvePackage({ - name, - url, - range -}) { +async function resolvePackage({ name, url, range }) { let version; let path; diff --git a/src/save-blueprint-file.js b/src/save-blueprint-file.js index 9ce551cd..d18d5eaa 100644 --- a/src/save-blueprint-file.js +++ b/src/save-blueprint-file.js @@ -4,32 +4,35 @@ const fs = require('fs-extra'); const path = require('path'); async function saveBlueprintFile(emberCliUpdateJsonPath, emberCliUpdateJson) { - emberCliUpdateJson.packages = emberCliUpdateJson.blueprints.reduce((packages, blueprint) => { - let _package = packages.find(p => p.name === blueprint.packageName); - - if (!_package) { - _package = { - name: blueprint.packageName, - location: blueprint.location, - version: blueprint.version, - blueprints: [] - }; - - packages.push(_package); - } - - _package.blueprints.push(blueprint); - - delete blueprint.packageName; - delete blueprint.location; - delete blueprint.version; - - if (!blueprint.options.length) { - delete blueprint.options; - } - - return packages; - }, []); + emberCliUpdateJson.packages = emberCliUpdateJson.blueprints.reduce( + (packages, blueprint) => { + let _package = packages.find(p => p.name === blueprint.packageName); + + if (!_package) { + _package = { + name: blueprint.packageName, + location: blueprint.location, + version: blueprint.version, + blueprints: [] + }; + + packages.push(_package); + } + + _package.blueprints.push(blueprint); + + delete blueprint.packageName; + delete blueprint.location; + delete blueprint.version; + + if (!blueprint.options.length) { + delete blueprint.options; + } + + return packages; + }, + [] + ); delete emberCliUpdateJson.blueprints; diff --git a/src/save-blueprint.js b/src/save-blueprint.js index 4cd15c50..21d8322e 100644 --- a/src/save-blueprint.js +++ b/src/save-blueprint.js @@ -7,10 +7,7 @@ function addBlueprint(emberCliUpdateJson, blueprint) { emberCliUpdateJson.blueprints.push(blueprint); } -async function saveBlueprint({ - emberCliUpdateJsonPath, - blueprint -}) { +async function saveBlueprint({ emberCliUpdateJsonPath, blueprint }) { if (!(blueprint && blueprint.version)) { blueprint = await utils.loadDefaultBlueprintFromDisk({ cwd: emberCliUpdateJsonPath @@ -29,7 +26,9 @@ async function saveBlueprint({ isBaseBlueprint } = blueprint; - let emberCliUpdateJson = await utils.loadSafeBlueprintFile(emberCliUpdateJsonPath); + let emberCliUpdateJson = await utils.loadSafeBlueprintFile( + emberCliUpdateJsonPath + ); let savedBlueprint = findBlueprint(emberCliUpdateJson, packageName, name); diff --git a/src/save.js b/src/save.js index 3d786e99..9b5d57c3 100644 --- a/src/save.js +++ b/src/save.js @@ -58,7 +58,7 @@ module.exports = async function save({ options: blueprintOptions }); - if (!await loadBlueprintFile(emberCliUpdateJsonPath)) { + if (!(await loadBlueprintFile(emberCliUpdateJsonPath))) { blueprint.isBaseBlueprint = true; } diff --git a/src/stage-blueprint-file.js b/src/stage-blueprint-file.js index 9af1b0d0..a373cdc7 100644 --- a/src/stage-blueprint-file.js +++ b/src/stage-blueprint-file.js @@ -3,10 +3,7 @@ const path = require('path'); const { spawn } = require('./run'); -async function stageBlueprintFile({ - cwd, - emberCliUpdateJsonPath -}) { +async function stageBlueprintFile({ cwd, emberCliUpdateJsonPath }) { let relative = path.relative(cwd, emberCliUpdateJsonPath); await spawn('git', ['add', relative], { diff --git a/src/stats.js b/src/stats.js index df376d90..cc33e9d7 100644 --- a/src/stats.js +++ b/src/stats.js @@ -22,9 +22,7 @@ module.exports = async function stats({ let { blueprints } = emberCliUpdateJson; if (blueprint) { - let { - existingBlueprint - } = await getBlueprintFromArgs({ + let { existingBlueprint } = await getBlueprintFromArgs({ cwd, emberCliUpdateJson, packageName, @@ -50,31 +48,39 @@ module.exports = async function stats({ let lines = [ `package name: ${blueprint.packageName}`, - ...blueprint.location ? [`package location: ${blueprint.location}`] : [], + ...(blueprint.location + ? [`package location: ${blueprint.location}`] + : []), `blueprint name: ${blueprint.name}`, `current version: ${blueprint.version}`, `latest version: ${blueprintUpdate.latestVersion}`, - ...blueprint.outputRepo ? [`output repo: ${blueprint.outputRepo}`] : [], - ...blueprint.options.length ? [`options: ${blueprint.options.join(', ')}`] : [], - ...blueprint.codemodsSource ? [ - `codemods source: ${blueprint.codemodsSource}`, - `applicable codemods: ${await (async() => { - let packageJson = require(path.join(cwd, 'package')); - let projectOptions = isDefaultBlueprint(blueprintUpdate.blueprint) - ? await getProjectOptions(packageJson, blueprint) - : blueprint.options; - let codemods = await utils.getApplicableCodemods({ - source: blueprint.codemodsSource, - projectOptions, - packageJson - }); - return Object.keys(codemods).join(', '); - })()}` - ] : [] + ...(blueprint.outputRepo ? [`output repo: ${blueprint.outputRepo}`] : []), + ...(blueprint.options.length + ? [`options: ${blueprint.options.join(', ')}`] + : []), + ...(blueprint.codemodsSource + ? [ + `codemods source: ${blueprint.codemodsSource}`, + `applicable codemods: ${await (async () => { + let packageJson = require(path.join(cwd, 'package')); + let projectOptions = isDefaultBlueprint(blueprintUpdate.blueprint) + ? await getProjectOptions(packageJson, blueprint) + : blueprint.options; + let codemods = await utils.getApplicableCodemods({ + source: blueprint.codemodsSource, + projectOptions, + packageJson + }); + return Object.keys(codemods).join(', '); + })()}` + ] + : []) ]; - stats.push(lines.join(` -`)); + stats.push( + lines.join(` +`) + ); } return stats.join(` diff --git a/test/acceptance/ember-cli-update-test.js b/test/acceptance/ember-cli-update-test.js index 1e21e49f..1d51c1f5 100644 --- a/test/acceptance/ember-cli-update-test.js +++ b/test/acceptance/ember-cli-update-test.js @@ -25,7 +25,7 @@ const select = ' '; const down = '\u001b[B'; const enter = '\n'; -describe(function() { +describe(function () { this.timeout(3 * 60e3); let tmpPath; @@ -54,48 +54,27 @@ describe(function() { await beforeMerge(); - let args = [ - ...to ? [`--to=${to}`] : [], - '--resolve-conflicts' - ]; + let args = [...(to ? [`--to=${to}`] : []), '--resolve-conflicts']; if (listCodemods || runCodemods) { - args = [ - 'codemods', - ...listCodemods ? ['--list'] : [] - ]; + args = ['codemods', ...(listCodemods ? ['--list'] : [])]; } if (init) { - args = [ - 'init', - ...to ? [`--to=${to}`] : [] - ]; + args = ['init', ...(to ? [`--to=${to}`] : [])]; } if (install) { - args = [ - 'install', - addon - ]; + args = ['install', addon]; } if (bootstrap) { - args = [ - 'bootstrap' - ]; + args = ['bootstrap']; } if (stats) { - args = [ - 'stats' - ]; + args = ['stats']; } if (save) { - args = [ - 'save' - ]; + args = ['save']; } if (reset) { - args = [ - 'reset', - ...to ? [`--to=${to}`] : [] - ]; + args = ['reset', ...(to ? [`--to=${to}`] : [])]; } if (blueprint) { // Keep this to `-b` to test the short alias @@ -115,10 +94,7 @@ describe(function() { }); } - function fixtureCompare({ - actual = tmpPath, - mergeFixtures - }) { + function fixtureCompare({ actual = tmpPath, mergeFixtures }) { let expected = mergeFixtures; _fixtureCompare({ @@ -128,13 +104,13 @@ describe(function() { }); } - it('works', async function() { - let { - status - } = await (await merge({ - fixturesPath: 'test/fixtures/app/local', - commitMessage: 'my-app' - })).promise; + it('works', async function () { + let { status } = await ( + await merge({ + fixturesPath: 'test/fixtures/app/local', + commitMessage: 'my-app' + }) + ).promise; fixtureCompare({ mergeFixtures: 'test/fixtures/app/merge/my-app' @@ -143,10 +119,13 @@ describe(function() { assertNoUnstaged(status); }); - it('runs codemods', async function() { + it('runs codemods', async function () { async function _merge(src, dest) { await fs.copy( - path.resolve(__dirname, `../fixtures/codemod/codemods/ember-modules-codemod/${src}/my-app`), + path.resolve( + __dirname, + `../fixtures/codemod/codemods/ember-modules-codemod/${src}/my-app` + ), dest, { overwrite: true, @@ -155,10 +134,7 @@ describe(function() { ); } - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/codemod/local', commitMessage: 'my-app', runCodemods: true, @@ -181,9 +157,7 @@ describe(function() { ps.stdout.on('data', stdoutData); }); - let { - status - } = await promise; + let { status } = await promise; assertNoUnstaged(status); assertCodemodRan(status); @@ -208,11 +182,8 @@ describe(function() { }); }); - it('has all up-to-date blueprints', async function() { - let { - ps, - promise - } = await merge({ + it('has all up-to-date blueprints', async function () { + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/remote-app/merge', commitMessage: 'my.app' }); @@ -230,25 +201,21 @@ describe(function() { ps.stdout.on('data', stdoutData); }); - let { - status - } = await promise; + let { status } = await promise; expect(await isGitClean({ cwd: tmpPath })).to.be.ok; expect(status).to.equal(''); }); - it('can pick from multiple blueprints', async function() { - let { - location, - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + it('can pick from multiple blueprints', async function () { + let { location, version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', to: null, @@ -299,9 +266,7 @@ describe(function() { await whichVersion; await customVersion; - let { - status - } = await promise; + let { status } = await promise; fixtureCompare({ mergeFixtures: 'test/fixtures/blueprint/app/local-app/merge/my-app' @@ -312,19 +277,20 @@ describe(function() { assertNoUnstaged(status); }); - it('can reset from multiple blueprint', async function() { - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/reset/local/my-app/config/ember-cli-update.json')).blueprints[1]; + it('can reset from multiple blueprint', async function () { + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/reset/local/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/reset/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/reset/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/reset/local', commitMessage: 'my-app', reset: true, @@ -351,9 +317,7 @@ describe(function() { }); await whichBlueprint; - let { - status - } = await promise; + let { status } = await promise; fixtureCompare({ mergeFixtures: 'test/fixtures/blueprint/app/local-app/reset/merge/my-app' @@ -362,15 +326,15 @@ describe(function() { assertNoStaged(status); }); - it('can init the default blueprint', async function() { - let { - status - } = await (await merge({ - fixturesPath: 'test/fixtures/app/local', - commitMessage: 'my-app', - init: true, - to: '2.11.1' - })).promise; + it('can init the default blueprint', async function () { + let { status } = await ( + await merge({ + fixturesPath: 'test/fixtures/app/local', + commitMessage: 'my-app', + init: true, + to: '2.11.1' + }) + ).promise; fixtureCompare({ mergeFixtures: 'test/fixtures/app/init/my-app' @@ -381,17 +345,16 @@ describe(function() { assertNoStaged(status); }); - it('can install an addon with a default blueprint and a state file', async function() { + it('can install an addon with a default blueprint and a state file', async function () { this.timeout(3 * 60e3); - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/addon/legacy-app/local/ideal', commitMessage: 'my-app', install: true, @@ -409,9 +372,7 @@ describe(function() { overwriteBlueprintFiles(ps); - let { - status - } = await promise; + let { status } = await promise; await fs.remove(path.join(tmpPath, 'package-lock.json')); @@ -422,18 +383,16 @@ describe(function() { assertNoStaged(status); }); - it('can update a legacy addon blueprint', async function() { + it('can update a legacy addon blueprint', async function () { this.timeout(5 * 60e3); - let { - name, - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/local/ideal/my-app/config/ember-cli-update.json')).blueprints[1]; + let { name, location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/local/ideal/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/addon/legacy-app/local/ideal', commitMessage: 'my-app', blueprint: name, @@ -450,9 +409,7 @@ describe(function() { overwriteBlueprintFiles(ps); - let { - status - } = await promise; + let { status } = await promise; assertNoUnstaged(status); @@ -465,18 +422,16 @@ describe(function() { // that peer-deps (requiring ember-cli internals) works // in existing npm addons // https://github.com/salsify/ember-cli-dependency-lint/blob/v1.0.3/lib/commands/dependency-lint.js#L5 - it('can update a npm addon blueprint with implicit peer dep', async function() { + it('can update a npm addon blueprint with implicit peer dep', async function () { this.timeout(5 * 60e3); - let { - name, - version - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/npm-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { name, version } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/npm-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - ps, - promise - } = await merge({ + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/addon/npm-app/local', commitMessage: 'my-app', blueprint: name, @@ -485,9 +440,7 @@ describe(function() { overwriteBlueprintFiles(ps); - let { - status - } = await promise; + let { status } = await promise; assertNoUnstaged(status); @@ -496,19 +449,22 @@ describe(function() { }); }); - it('can bootstrap the default blueprint', async function() { - let { - status - } = await (await merge({ - fixturesPath: 'test/fixtures/app/local', - commitMessage: 'my-app', - bootstrap: true - })).promise; + it('can bootstrap the default blueprint', async function () { + let { status } = await ( + await merge({ + fixturesPath: 'test/fixtures/app/local', + commitMessage: 'my-app', + bootstrap: true + }) + ).promise; assertNoStaged(status); - expect(path.join(tmpPath, 'config/ember-cli-update.json')).to.be.a.file() - .and.equal('test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json'); + expect(path.join(tmpPath, 'config/ember-cli-update.json')) + .to.be.a.file() + .and.equal( + 'test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ); await fs.remove(path.join(tmpPath, 'config/ember-cli-update.json')); @@ -517,30 +473,27 @@ describe(function() { }); }); - it('can save an old blueprint\'s state', async function() { + it("can save an old blueprint's state", async function () { let [ - { - packageName, - version: base - }, - { - location, - version: partial, - outputRepo, - codemodsSource, - options - } - ] = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints; + { packageName, version: base }, + { location, version: partial, outputRepo, codemodsSource, options } + ] = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json' + ) + ).blueprints; let commitMessage = 'my-app'; - await (await merge({ - fixturesPath: 'test/fixtures/blueprint/app/local-app/init/local', - commitMessage, - save: true, - from: base, - blueprint: packageName - })).promise; + await ( + await merge({ + fixturesPath: 'test/fixtures/blueprint/app/local-app/init/local', + commitMessage, + save: true, + from: base, + blueprint: packageName + }) + ).promise; await initBlueprint({ fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/local'), @@ -548,22 +501,22 @@ describe(function() { relativeDir: location }); - let { - status - } = await (await processBin({ - binFile: 'ember-cli-update', - args: [ - 'save', - `-b=${location}`, - `--from=${partial}`, - `--output-repo=${outputRepo}`, - `--codemods-source=${codemodsSource}`, - ...options - ], - cwd: tmpPath, - commitMessage, - expect - })).promise; + let { status } = await ( + await processBin({ + binFile: 'ember-cli-update', + args: [ + 'save', + `-b=${location}`, + `--from=${partial}`, + `--output-repo=${outputRepo}`, + `--codemods-source=${codemodsSource}`, + ...options + ], + cwd: tmpPath, + commitMessage, + expect + }) + ).promise; assertNoStaged(status); @@ -573,21 +526,24 @@ describe(function() { }); }); - it('can show single blueprint stats', async function() { + it('can show single blueprint stats', async function () { let { packageName, name, version: from - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints[0]; - - let { - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints[0]; - - let { - ps, - promise - } = await merge({ + } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json' + ) + ).blueprints[0]; + + let { version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[0]; + + let { ps, promise } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', stats: true, @@ -601,9 +557,7 @@ describe(function() { result += str; }); - let { - status - } = await promise; + let { status } = await promise; assertNoStaged(status); diff --git a/test/helpers/assertions.js b/test/helpers/assertions.js index 57ce968d..2fa3afcb 100644 --- a/test/helpers/assertions.js +++ b/test/helpers/assertions.js @@ -2,14 +2,14 @@ const { expect } = require('./chai'); -module.exports.assertNoUnstaged = function(status) { +module.exports.assertNoUnstaged = function (status) { expect(status).to.not.match(/^.\w/m); }; -module.exports.assertNoStaged = function(status) { +module.exports.assertNoStaged = function (status) { expect(status).to.not.match(/^\w/m); }; -module.exports.assertCodemodRan = function(status) { +module.exports.assertCodemodRan = function (status) { expect(status).to.match(/^A {2}.*/m); }; diff --git a/test/helpers/blueprint.js b/test/helpers/blueprint.js index d3e625b4..2e269c47 100644 --- a/test/helpers/blueprint.js +++ b/test/helpers/blueprint.js @@ -4,11 +4,7 @@ const path = require('path'); const fs = require('fs-extra'); const { buildTmp } = require('git-fixtures'); -async function initBlueprint({ - fixturesPath, - resolvedFrom, - relativeDir -}) { +async function initBlueprint({ fixturesPath, resolvedFrom, relativeDir }) { let blueprintPath = await buildTmp({ fixturesPath }); diff --git a/test/integration/check-for-blueprint-updates-test.js b/test/integration/check-for-blueprint-updates-test.js index a88adbb0..a0d977fb 100644 --- a/test/integration/check-for-blueprint-updates-test.js +++ b/test/integration/check-for-blueprint-updates-test.js @@ -7,22 +7,34 @@ const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const { createTmpDir } = require('../../src/tmp'); -describe(checkForBlueprintUpdates, function() { +describe(checkForBlueprintUpdates, function () { this.timeout(30e3); let tmpPath; - beforeEach(async function() { + beforeEach(async function () { tmpPath = await createTmpDir(); }); - it('works', async function() { + it('works', async function () { // out of date test - let localBlueprint = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints[1]; - let urlBlueprint = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/remote-app/local/my.app/config/ember-cli-update.json')).blueprints[0]; + let localBlueprint = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; + let urlBlueprint = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/remote-app/local/my.app/config/ember-cli-update.json' + ) + ).blueprints[0]; // up to date test - let npmBlueprint = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let npmBlueprint = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; await initBlueprint({ fixturesPath: 'test/fixtures/blueprint/app/local', @@ -32,22 +44,26 @@ describe(checkForBlueprintUpdates, function() { let blueprintUpdates = await checkForBlueprintUpdates({ cwd: tmpPath, - blueprints: [ - localBlueprint, - urlBlueprint, - npmBlueprint - ] + blueprints: [localBlueprint, urlBlueprint, npmBlueprint] }); expect(blueprintUpdates).to.deep.equal([ { blueprint: localBlueprint, - latestVersion: (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints[1].version, + latestVersion: ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1].version, isUpToDate: false }, { blueprint: urlBlueprint, - latestVersion: (await loadSafeBlueprintFile('test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json')).blueprints[0].version, + latestVersion: ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json' + ) + ).blueprints[0].version, isUpToDate: false }, { diff --git a/test/integration/codemods-test.js b/test/integration/codemods-test.js index 36f2f53c..d9f75ce6 100644 --- a/test/integration/codemods-test.js +++ b/test/integration/codemods-test.js @@ -2,17 +2,12 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); -const { - buildTmp, - processExit -} = require('git-fixtures'); +const { buildTmp, processExit } = require('git-fixtures'); const { isGitClean } = require('git-diff-apply'); const codemods = require('../../src/codemods'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); -describe(codemods, function() { +describe(codemods, function () { this.timeout(30e3); let tmpPath; @@ -46,10 +41,8 @@ describe(codemods, function() { }); } - it('lists codemods', async function() { - let { - result - } = await merge({ + it('lists codemods', async function () { + let { result } = await merge({ fixturesPath: 'test/fixtures/codemod/local', commitMessage: 'my-app', list: true @@ -62,10 +55,8 @@ describe(codemods, function() { expect(JSON.parse(result)).to.have.own.property('ember-modules-codemod'); }); - it('accepts codemods via json string', async function() { - let { - result - } = await merge({ + it('accepts codemods via json string', async function () { + let { result } = await merge({ fixturesPath: 'test/fixtures/codemod/local', commitMessage: 'my-app', list: true, @@ -86,11 +77,8 @@ describe(codemods, function() { expect(JSON.parse(result)).to.have.own.property('test-codemod-json'); }); - it('handles missing blueprint', async function() { - let { - stderr, - status - } = await merge({ + it('handles missing blueprint', async function () { + let { stderr, status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', blueprint: 'missing' diff --git a/test/integration/compare-test.js b/test/integration/compare-test.js index 71a59f0e..53417a42 100644 --- a/test/integration/compare-test.js +++ b/test/integration/compare-test.js @@ -4,11 +4,7 @@ const fs = require('fs-extra'); const path = require('path'); const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); -const { - buildTmp, - processExit, - commit -} = require('git-fixtures'); +const { buildTmp, processExit, commit } = require('git-fixtures'); const { isGitClean } = require('git-diff-apply'); const compare = require('../../src/compare'); const { initBlueprint } = require('../helpers/blueprint'); @@ -17,17 +13,17 @@ const utils = require('boilerplate-update/src/utils'); const sinon = require('sinon'); const inquirer = require('inquirer'); -describe(compare, function() { +describe(compare, function () { this.timeout(30e3); let tmpPath; let open; - beforeEach(function() { + beforeEach(function () { open = sinon.stub(utils, 'open'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); @@ -60,25 +56,30 @@ describe(compare, function() { }); } - it('works', async function() { - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints[1]; + it('works', async function () { + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - result - } = await merge({ + let { result } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', blueprint: location, to, async beforeMerge() { await initBlueprint({ - fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/local'), + fixturesPath: path.resolve( + __dirname, + '../fixtures/blueprint/app/local' + ), resolvedFrom: tmpPath, relativeDir: location }); @@ -87,16 +88,16 @@ describe(compare, function() { expect(await isGitClean({ cwd: tmpPath })).to.be.ok; - expect(result, 'don\'t accidentally print anything to the console').to.be.undefined; + expect(result, "don't accidentally print anything to the console").to.be + .undefined; - expect(open).to.have.been.calledOnce - .and.to.have.been.calledWith('https://github.com/test/output-repo/compare/v0.0.1...v0.0.2'); + expect(open).to.have.been.calledOnce.and.to.have.been.calledWith( + 'https://github.com/test/output-repo/compare/v0.0.1...v0.0.2' + ); }); - it('handles missing blueprint', async function() { - let { - stderr - } = await merge({ + it('handles missing blueprint', async function () { + let { stderr } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', blueprint: 'missing' @@ -107,7 +108,7 @@ describe(compare, function() { expect(stderr).to.equal('blueprint "missing" was not found'); }); - it('works for the default blueprint without a state file', async function() { + it('works for the default blueprint without a state file', async function () { await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app' @@ -115,17 +116,23 @@ describe(compare, function() { expect(await isGitClean({ cwd: tmpPath })).to.be.ok; - expect(open).to.have.been.calledOnce - .and.to.have.been.calledWith('https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1'); + expect(open).to.have.been.calledOnce.and.to.have.been.calledWith( + 'https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1' + ); }); - it('works for the default blueprint with a state file', async function() { - sinon.stub(inquirer, 'prompt').withArgs([{ - type: 'list', - message: 'Which blueprint would you like to compare?', - name: 'blueprint', - choices: [{ name: 'ember-cli' }] - }]).resolves({ blueprint: 'ember-cli' }); + it('works for the default blueprint with a state file', async function () { + sinon + .stub(inquirer, 'prompt') + .withArgs([ + { + type: 'list', + message: 'Which blueprint would you like to compare?', + name: 'blueprint', + choices: [{ name: 'ember-cli' }] + } + ]) + .resolves({ blueprint: 'ember-cli' }); let commitMessage = 'my-app'; @@ -134,7 +141,10 @@ describe(compare, function() { commitMessage, async beforeMerge() { await fs.copy( - path.resolve(__dirname, '../fixtures/ember-cli-update-json/default/config/ember-cli-update.json'), + path.resolve( + __dirname, + '../fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ), path.join(tmpPath, 'config/ember-cli-update.json') ); @@ -144,15 +154,17 @@ describe(compare, function() { expect(await isGitClean({ cwd: tmpPath })).to.be.ok; - expect(open).to.have.been.calledOnce - .and.to.have.been.calledWith('https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1'); + expect(open).to.have.been.calledOnce.and.to.have.been.calledWith( + 'https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1' + ); }); - it('works for a default blueprint by name', async function() { - let { - packageName, - name: blueprint - } = (await loadSafeBlueprintFile('test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json')).blueprints[0]; + it('works for a default blueprint by name', async function () { + let { packageName, name: blueprint } = ( + await loadSafeBlueprintFile( + 'test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ) + ).blueprints[0]; let commitMessage = 'my-app'; @@ -163,7 +175,10 @@ describe(compare, function() { blueprint, async beforeMerge() { await fs.copy( - path.resolve(__dirname, '../fixtures/ember-cli-update-json/default/config/ember-cli-update.json'), + path.resolve( + __dirname, + '../fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ), path.join(tmpPath, 'config/ember-cli-update.json') ); @@ -173,7 +188,8 @@ describe(compare, function() { expect(await isGitClean({ cwd: tmpPath })).to.be.ok; - expect(open).to.have.been.calledOnce - .and.to.have.been.calledWith('https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1'); + expect(open).to.have.been.calledOnce.and.to.have.been.calledWith( + 'https://github.com/ember-cli/ember-new-output/compare/v2.11.1...v3.11.0-beta.1' + ); }); }); diff --git a/test/integration/download-package-test.js b/test/integration/download-package-test.js index 217d13a2..50a31e9b 100644 --- a/test/integration/download-package-test.js +++ b/test/integration/download-package-test.js @@ -11,27 +11,34 @@ const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const { createTmpDir } = require('../../src/tmp'); const fs = require('fs-extra'); -describe(downloadPackage, function() { +describe(downloadPackage, function () { this.timeout(30e3); let tmpPath; - beforeEach(async function() { + beforeEach(async function () { tmpPath = path.join(await createTmpDir(), 'app'); await fs.mkdir(tmpPath); }); - it('throws if missing a range', async function() { - await expect(downloadPackage('test-name', 'test-url', null)) - .to.eventually.be.rejectedWith('Missing a range when downloading blueprint'); + it('throws if missing a range', async function () { + await expect( + downloadPackage('test-name', 'test-url', null) + ).to.eventually.be.rejectedWith( + 'Missing a range when downloading blueprint' + ); }); - it('downloads local paths as urls', async function() { + it('downloads local paths as urls', async function () { let { name, location, version: range - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; let blueprintPath = await initBlueprint({ fixturesPath: 'test/fixtures/blueprint/app/local', @@ -50,12 +57,16 @@ describe(downloadPackage, function() { expect(downloadedPackage.version).to.equal(range); }); - it('downloads urls', async function() { + it('downloads urls', async function () { let { name, location: url, version: range - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json')).blueprints[0]; + } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json' + ) + ).blueprints[0]; let downloadedPackage = await downloadPackage(null, url, range); @@ -64,11 +75,12 @@ describe(downloadPackage, function() { expect(downloadedPackage.version).to.equal(range); }); - it('downloads npm packages', async function() { - let { - name, - version: range - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + it('downloads npm packages', async function () { + let { name, version: range } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; let downloadedPackage = await downloadPackage(name, null, range); diff --git a/test/integration/get-blueprint-file-path-test.js b/test/integration/get-blueprint-file-path-test.js index ff16804d..1f64a210 100644 --- a/test/integration/get-blueprint-file-path-test.js +++ b/test/integration/get-blueprint-file-path-test.js @@ -7,8 +7,8 @@ const path = require('path'); const { getBlueprintRelativeFilePath } = getBlueprintFilePath; -describe(getBlueprintFilePath, function() { - it('doesn\'t have an ember-addon key', async function() { +describe(getBlueprintFilePath, function () { + it("doesn't have an ember-addon key", async function () { let dir = 'test/fixtures/package-json/no-ember-addon'; let expected = 'config/ember-cli-update.json'; @@ -17,7 +17,7 @@ describe(getBlueprintFilePath, function() { expect(filePath).to.endWith(path.join(dir, expected)); }); - it('doesn\'t have a custom config dir', async function() { + it("doesn't have a custom config dir", async function () { let dir = 'test/fixtures/package-json/no-config-path'; let expected = 'config/ember-cli-update.json'; @@ -26,7 +26,7 @@ describe(getBlueprintFilePath, function() { expect(filePath).to.endWith(path.join(dir, expected)); }); - it('uses a custom config dir', async function() { + it('uses a custom config dir', async function () { let dir = 'test/fixtures/package-json/config-path'; let expected = 'config2/ember-cli-update.json'; @@ -35,8 +35,8 @@ describe(getBlueprintFilePath, function() { expect(filePath).to.endWith(path.join(dir, expected)); }); - describe(getBlueprintRelativeFilePath, function() { - it('doesn\'t have an ember-addon key', async function() { + describe(getBlueprintRelativeFilePath, function () { + it("doesn't have an ember-addon key", async function () { let dir = 'test/fixtures/package-json/no-ember-addon'; let expected = 'config/ember-cli-update.json'; @@ -45,7 +45,7 @@ describe(getBlueprintFilePath, function() { expect(filePath).to.equal(path.normalize(expected)); }); - it('doesn\'t have a custom config dir', async function() { + it("doesn't have a custom config dir", async function () { let dir = 'test/fixtures/package-json/no-config-path'; let expected = 'config/ember-cli-update.json'; @@ -54,7 +54,7 @@ describe(getBlueprintFilePath, function() { expect(filePath).to.equal(path.normalize(expected)); }); - it('uses a custom config dir', async function() { + it('uses a custom config dir', async function () { let dir = 'test/fixtures/package-json/config-path'; let expected = 'config2/ember-cli-update.json'; diff --git a/test/integration/get-default-blueprint-name-override-test.js b/test/integration/get-default-blueprint-name-override-test.js index d55c27cb..d287c349 100644 --- a/test/integration/get-default-blueprint-name-override-test.js +++ b/test/integration/get-default-blueprint-name-override-test.js @@ -4,23 +4,31 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const getBlueprintNameOverride = require('../../src/get-default-blueprint-name-override'); -describe(getBlueprintNameOverride, function() { - it('local package with non-default returns expected value', async function() { - let localPackageFixture = '../fixtures/blueprint/addon/default-blueprint-different-than-name/v0.0.1'; +describe(getBlueprintNameOverride, function () { + it('local package with non-default returns expected value', async function () { + let localPackageFixture = + '../fixtures/blueprint/addon/default-blueprint-different-than-name/v0.0.1'; - let defaultBlueprintOverride = await getBlueprintNameOverride(localPackageFixture, __dirname); + let defaultBlueprintOverride = await getBlueprintNameOverride( + localPackageFixture, + __dirname + ); expect(defaultBlueprintOverride).to.be.equal('custom-blueprint'); }); - it('NPM package with non-default returns expected value', async function() { - let defaultBlueprintOverride = await getBlueprintNameOverride('ember-cli-update-default-blueprint-override-test'); + it('NPM package with non-default returns expected value', async function () { + let defaultBlueprintOverride = await getBlueprintNameOverride( + 'ember-cli-update-default-blueprint-override-test' + ); expect(defaultBlueprintOverride).to.be.equal('hello-world'); }); - it('missing NPM package returns null', async function() { - let defaultBlueprintOverride = await getBlueprintNameOverride('this-is-hopefully-missing'); + it('missing NPM package returns null', async function () { + let defaultBlueprintOverride = await getBlueprintNameOverride( + 'this-is-hopefully-missing' + ); expect(defaultBlueprintOverride).to.be.null; }); diff --git a/test/integration/has-yarn-test.js b/test/integration/has-yarn-test.js index 4a0c682f..e615b281 100644 --- a/test/integration/has-yarn-test.js +++ b/test/integration/has-yarn-test.js @@ -7,18 +7,18 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const hasYarn = require('../../src/has-yarn'); -describe(hasYarn, function() { - beforeEach(async function() { +describe(hasYarn, function () { + beforeEach(async function () { this.tempDir = await createTmpDir(); }); - it('project with no yarn.lock returns false', async function() { + it('project with no yarn.lock returns false', async function () { let result = await hasYarn(this.tempDir); expect(result).to.be.false; }); - it('project with yarn.lock returns true', async function() { + it('project with yarn.lock returns true', async function () { await fs.writeFile(path.join(this.tempDir, 'yarn.lock'), ''); let result = await hasYarn(this.tempDir); diff --git a/test/integration/index-test.js b/test/integration/index-test.js index e8142c0b..7f38cfbd 100644 --- a/test/integration/index-test.js +++ b/test/integration/index-test.js @@ -13,9 +13,7 @@ const { } = require('git-fixtures'); const { isGitClean } = require('git-diff-apply'); const emberCliUpdate = require('../../src'); -const { - assertNoUnstaged -} = require('../helpers/assertions'); +const { assertNoUnstaged } = require('../helpers/assertions'); const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const { @@ -25,12 +23,12 @@ const { } = require('../../src/constants'); const { EOL } = require('os'); -describe(function() { +describe(function () { this.timeout(90e3); let tmpPath; - afterEach(function() { + afterEach(function () { sinon.restore(); }); @@ -52,14 +50,16 @@ describe(function() { await beforeMerge(); - let promise = (async() => { - let result = await (await emberCliUpdate({ - cwd: tmpPath, - packageName, - blueprint, - from, - to - })).promise; + let promise = (async () => { + let result = await ( + await emberCliUpdate({ + cwd: tmpPath, + packageName, + blueprint, + from, + to + }) + ).promise; await afterMerge(); @@ -74,9 +74,7 @@ describe(function() { }); } - function fixtureCompare({ - mergeFixtures - }) { + function fixtureCompare({ mergeFixtures }) { let actual = tmpPath; let expected = mergeFixtures; @@ -87,11 +85,8 @@ describe(function() { }); } - it('handles dirty', async function() { - let { - status, - stderr - } = await merge({ + it('handles dirty', async function () { + let { status, stderr } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app', dirty: true @@ -104,22 +99,21 @@ describe(function() { expect(stderr).to.not.contain('UnhandledPromiseRejectionWarning'); }); - it('handles non-ember-cli app', async function() { + it('handles non-ember-cli app', async function () { let promise = merge({ fixturesPath: 'test/fixtures/package-json/non-ember-cli', commitMessage: 'my-app' }); - await expect(promise) - .to.eventually.be.rejectedWith('Ember CLI project type could not be determined'); + await expect(promise).to.eventually.be.rejectedWith( + 'Ember CLI project type could not be determined' + ); expect(await isGitClean({ cwd: tmpPath })).to.be.ok; }); - it('handles non-npm dir', async function() { - let { - stderr - } = await merge({ + it('handles non-npm dir', async function () { + let { stderr } = await merge({ fixturesPath: 'test/fixtures/package-json/missing', commitMessage: 'my-app' }); @@ -129,10 +123,8 @@ describe(function() { expect(stderr).to.contain('No package.json was found in this directory'); }); - it('handles malformed package.json', async function() { - let { - stderr - } = await merge({ + it('handles malformed package.json', async function () { + let { stderr } = await merge({ fixturesPath: 'test/fixtures/package-json/malformed', commitMessage: 'my-app' }); @@ -142,10 +134,8 @@ describe(function() { expect(stderr).to.contain('The package.json is malformed'); }); - it('updates glimmer app', async function() { - let { - status - } = await merge({ + it('updates glimmer app', async function () { + let { status } = await merge({ fixturesPath: 'test/fixtures/glimmer/local', commitMessage: 'glimmer-app', from: '0.5.0', @@ -161,10 +151,8 @@ describe(function() { assertNoUnstaged(status); }); - it('needs --from if glimmer app before 0.6.3', async function() { - let { - stderr - } = await merge({ + it('needs --from if glimmer app before 0.6.3', async function () { + let { stderr } = await merge({ fixturesPath: 'test/fixtures/glimmer/local', commitMessage: 'glimmer-app', to: '0.6.1' @@ -175,10 +163,8 @@ describe(function() { expect(stderr).to.contain('version cannot be determined'); }); - it('updates addon', async function() { - let { - status - } = await merge({ + it('updates addon', async function () { + let { status } = await merge({ fixturesPath: 'test/fixtures/addon/local', commitMessage: 'my-addon' }); @@ -190,29 +176,30 @@ describe(function() { assertNoUnstaged(status); }); - describe('blueprints', function() { - describe('--blueprint', function() { - it('throws if missing --from', async function() { + describe('blueprints', function () { + describe('--blueprint', function () { + it('throws if missing --from', async function () { let promise = merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app', blueprint: 'test-blueprint' }); - await expect(promise).to.eventually.be.rejectedWith('A custom blueprint cannot detect --from. You must supply it.'); + await expect(promise).to.eventually.be.rejectedWith( + 'A custom blueprint cannot detect --from. You must supply it.' + ); expect(await isGitClean({ cwd: tmpPath })).to.be.ok; }); - it('can update a legacy blueprint', async function() { - let { - location, - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/legacy-app/merge/my-app/config2/ember-cli-update.json')).blueprints[1]; + it('can update a legacy blueprint', async function () { + let { location, version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/legacy-app/merge/my-app/config2/ember-cli-update.json' + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/legacy-app/local', commitMessage: 'my-app', blueprint: location, @@ -233,10 +220,8 @@ describe(function() { assertNoUnstaged(status); }); - it('can update a default blueprint by name', async function() { - let { - status - } = await merge({ + it('can update a default blueprint by name', async function () { + let { status } = await merge({ fixturesPath: 'test/fixtures/addon/local', commitMessage: 'my-addon', packageName: defaultPackageName, @@ -250,17 +235,16 @@ describe(function() { assertNoUnstaged(status); }); - it('ignores package.json version of ember-cli', async function() { - let { - packageName, - name: blueprint - } = (await loadSafeBlueprintFile('test/fixtures/ember-cli-update-json/addon/config/ember-cli-update.json')).blueprints[0]; + it('ignores package.json version of ember-cli', async function () { + let { packageName, name: blueprint } = ( + await loadSafeBlueprintFile( + 'test/fixtures/ember-cli-update-json/addon/config/ember-cli-update.json' + ) + ).blueprints[0]; let commitMessage = 'my-addon'; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/addon/local', commitMessage, packageName, @@ -268,14 +252,20 @@ describe(function() { // from: '2.11.1', async beforeMerge() { await fs.copy( - path.resolve(__dirname, '../fixtures/ember-cli-update-json/addon/config/ember-cli-update.json'), + path.resolve( + __dirname, + '../fixtures/ember-cli-update-json/addon/config/ember-cli-update.json' + ), path.join(tmpPath, 'tests/dummy/config/ember-cli-update.json') ); let packageJsonPath = path.join(tmpPath, 'package.json'); let packageJson = require(packageJsonPath); packageJson.devDependencies['ember-cli'] = '~3.11.0-beta.1'; - await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + EOL); + await fs.writeFile( + packageJsonPath, + JSON.stringify(packageJson, null, 2) + EOL + ); await commit({ m: commitMessage, cwd: tmpPath }); } @@ -289,18 +279,17 @@ describe(function() { }); }); - describe('ember-cli-update.json', function() { - it('can update a remote blueprint', async function() { + describe('ember-cli-update.json', function () { + it('can update a remote blueprint', async function () { this.timeout(1.5 * 60e3); - let { - name, - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json')).blueprints[0]; + let { name, version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/remote-app/merge/my.app/config/ember-cli-update.json' + ) + ).blueprints[0]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/remote-app/local', commitMessage: 'my.app', blueprint: name, @@ -314,19 +303,14 @@ describe(function() { assertNoUnstaged(status); }); - it('can update an npm blueprint', async function() { - let [ - { - location - }, - { - name - } - ] = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json')).blueprints; + it('can update an npm blueprint', async function () { + let [{ location }, { name }] = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/npm-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/npm-app/local', commitMessage: 'my-app', blueprint: name, @@ -350,19 +334,19 @@ describe(function() { }); }); - describe('Long running tests', function() { + describe('Long running tests', function () { this.timeout(4 * 60e3); - it('can update a custom blueprint for an ember app project', async function() { - let finalStateFixturePath = 'test/fixtures/app/non-default-addon-blueprint/local/my-app'; - let { - location, - version: to - } = (await loadSafeBlueprintFile(path.join(finalStateFixturePath, '/config/ember-cli-update.json'))).blueprints[1]; + it('can update a custom blueprint for an ember app project', async function () { + let finalStateFixturePath = + 'test/fixtures/app/non-default-addon-blueprint/local/my-app'; + let { location, version: to } = ( + await loadSafeBlueprintFile( + path.join(finalStateFixturePath, '/config/ember-cli-update.json') + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/app/non-default-addon-blueprint/local', commitMessage: 'my-app', packageName: location, diff --git a/test/integration/init-test.js b/test/integration/init-test.js index 16cb7531..dcd70066 100644 --- a/test/integration/init-test.js +++ b/test/integration/init-test.js @@ -9,9 +9,7 @@ const { fixtureCompare: _fixtureCompare } = require('git-fixtures'); const init = require('../../src/init'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const { @@ -19,7 +17,7 @@ const { defaultAppBlueprintName } = require('../../src/constants'); -describe(init, function() { +describe(init, function () { this.timeout(60e3); let tmpPath; @@ -59,9 +57,7 @@ describe(init, function() { }); } - function fixtureCompare({ - mergeFixtures - }) { + function fixtureCompare({ mergeFixtures }) { let actual = tmpPath; let expected = mergeFixtures; @@ -72,17 +68,14 @@ describe(init, function() { }); } - it('can initialize a custom blueprint', async function() { - let { - location, - outputRepo, - codemodsSource, - options - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/init/merge/my-app/config/ember-cli-update.json')).blueprints[0]; + it('can initialize a custom blueprint', async function () { + let { location, outputRepo, codemodsSource, options } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/init/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[0]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/init/local', commitMessage: 'my-app', blueprint: location, @@ -91,7 +84,10 @@ describe(init, function() { blueprintOptions: options, async beforeMerge() { await initBlueprint({ - fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/local'), + fixturesPath: path.resolve( + __dirname, + '../fixtures/blueprint/app/local' + ), resolvedFrom: tmpPath, relativeDir: location }); @@ -105,10 +101,8 @@ describe(init, function() { assertNoStaged(status); }); - it('can initialize a default blueprint by name', async function() { - let { - status - } = await merge({ + it('can initialize a default blueprint by name', async function () { + let { status } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app', packageName: defaultPackageName, diff --git a/test/integration/install-test.js b/test/integration/install-test.js index a97f909e..4d913f93 100644 --- a/test/integration/install-test.js +++ b/test/integration/install-test.js @@ -11,13 +11,11 @@ const { } = require('git-fixtures'); const install = require('../../src/install'); const { spawn } = require('../../src/run'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); -describe(install, function() { +describe(install, function () { this.timeout(60e3); let tmpPath; @@ -36,7 +34,7 @@ describe(install, function() { await beforeMerge(); - let promise = (async() => { + let promise = (async () => { let result = await install({ cwd: tmpPath, addon, @@ -56,9 +54,7 @@ describe(install, function() { }); } - function fixtureCompare({ - mergeFixtures - }) { + function fixtureCompare({ mergeFixtures }) { let actual = tmpPath; let expected = mergeFixtures; @@ -69,14 +65,14 @@ describe(install, function() { }); } - it('can install an addon with a default blueprint and no state file', async function() { - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + it('can install an addon with a default blueprint and no state file', async function () { + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/addon/legacy-app/local/no-addon', commitMessage: 'my-app', addon: location, @@ -101,14 +97,14 @@ describe(install, function() { assertNoStaged(status); }); - it('can install an addon with a custom default blueprint selected', async function() { - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + it('can install an addon with a custom default blueprint selected', async function () { + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ blueprintName: 'custom-blueprint', fixturesPath: 'test/fixtures/blueprint/addon/legacy-app/local/no-addon', commitMessage: 'my-app', @@ -128,21 +124,23 @@ describe(install, function() { }); fixtureCompare({ - mergeFixtures: 'test/fixtures/blueprint/addon/legacy-app/merge/my-app-generated-custom-blueprint' + mergeFixtures: + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app-generated-custom-blueprint' }); assertNoStaged(status); }); - it('can install an addon with a custom blueprint that does not match package name', async function() { - let addonContainingBlueprint = 'test/fixtures/blueprint/addon/default-blueprint-different-than-name'; - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/merge/my-app-install-blueprint-different-than-name/config/ember-cli-update.json')).blueprints[1]; + it('can install an addon with a custom blueprint that does not match package name', async function () { + let addonContainingBlueprint = + 'test/fixtures/blueprint/addon/default-blueprint-different-than-name'; + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app-install-blueprint-different-than-name/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/addon/legacy-app/local/no-addon', commitMessage: 'my-app', addon: location, @@ -161,7 +159,8 @@ describe(install, function() { }); fixtureCompare({ - mergeFixtures: 'test/fixtures/blueprint/addon/legacy-app/merge/my-app-install-blueprint-different-than-name' + mergeFixtures: + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app-install-blueprint-different-than-name' }); assertNoStaged(status); diff --git a/test/integration/load-blueprint-file-test.js b/test/integration/load-blueprint-file-test.js index 0ee52bf7..d3953850 100644 --- a/test/integration/load-blueprint-file-test.js +++ b/test/integration/load-blueprint-file-test.js @@ -4,16 +4,17 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const loadBlueprintFile = require('../../src/load-blueprint-file'); -describe(loadBlueprintFile, function() { - it('doesn\'t throw when missing', async function() { - let dir = 'test/fixtures/ember-cli-update-json/missing/ember-cli-update.json'; +describe(loadBlueprintFile, function () { + it("doesn't throw when missing", async function () { + let dir = + 'test/fixtures/ember-cli-update-json/missing/ember-cli-update.json'; let emberCliUpdateJson = await loadBlueprintFile(dir); expect(emberCliUpdateJson).to.be.undefined; }); - it('doesn\'t populate when empty', async function() { + it("doesn't populate when empty", async function () { let dir = 'test/fixtures/ember-cli-update-json/empty/ember-cli-update.json'; let emberCliUpdateJson = await loadBlueprintFile(dir); @@ -21,8 +22,9 @@ describe(loadBlueprintFile, function() { expect(emberCliUpdateJson).to.deep.equal({}); }); - it('works', async function() { - let dir = 'test/fixtures/ember-cli-update-json/normal/ember-cli-update.json'; + it('works', async function () { + let dir = + 'test/fixtures/ember-cli-update-json/normal/ember-cli-update.json'; let emberCliUpdateJson = await loadBlueprintFile(dir); diff --git a/test/integration/load-default-blueprint-test.js b/test/integration/load-default-blueprint-test.js index 7a954d42..ff0582e6 100644 --- a/test/integration/load-default-blueprint-test.js +++ b/test/integration/load-default-blueprint-test.js @@ -6,10 +6,10 @@ const _loadDefaultBlueprint = require('../../src/load-default-blueprint'); const version = '1.2.3'; -describe(_loadDefaultBlueprint, function() { +describe(_loadDefaultBlueprint, function () { let projectOptions; - beforeEach(function() { + beforeEach(function () { projectOptions = []; }); @@ -17,7 +17,7 @@ describe(_loadDefaultBlueprint, function() { return _loadDefaultBlueprint(projectOptions, version); } - it('returns blank blueprint if no params', async function() { + it('returns blank blueprint if no params', async function () { let blueprint = _loadDefaultBlueprint(); expect(blueprint).to.deep.equal({ @@ -27,23 +27,21 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/undefined/undefined', codemodsSource: 'ember-app-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--no-welcome' - ] + options: ['--no-welcome'] }); }); - describe('app', function() { - beforeEach(function() { + describe('app', function () { + beforeEach(function () { projectOptions.push('app'); }); - describe('welcome', function() { - beforeEach(function() { + describe('welcome', function () { + beforeEach(function () { projectOptions.push('welcome'); }); - it('npm', async function() { + it('npm', async function () { let blueprint = loadDefaultBlueprint(); expect(blueprint).to.deep.equal({ @@ -57,7 +55,7 @@ describe(_loadDefaultBlueprint, function() { }); }); - it('yarn', async function() { + it('yarn', async function () { projectOptions.push('yarn'); let blueprint = loadDefaultBlueprint(); @@ -69,15 +67,13 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/ember-cli/ember-new-output', codemodsSource: 'ember-app-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--yarn' - ] + options: ['--yarn'] }); }); }); - describe('no welcome', function() { - it('npm', async function() { + describe('no welcome', function () { + it('npm', async function () { let blueprint = loadDefaultBlueprint(); expect(blueprint).to.deep.equal({ @@ -87,13 +83,11 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/ember-cli/ember-new-output', codemodsSource: 'ember-app-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--no-welcome' - ] + options: ['--no-welcome'] }); }); - it('yarn', async function() { + it('yarn', async function () { projectOptions.push('yarn'); let blueprint = loadDefaultBlueprint(); @@ -105,21 +99,18 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/ember-cli/ember-new-output', codemodsSource: 'ember-app-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--yarn', - '--no-welcome' - ] + options: ['--yarn', '--no-welcome'] }); }); }); }); - describe('addon', function() { - beforeEach(function() { + describe('addon', function () { + beforeEach(function () { projectOptions.push('addon'); }); - it('npm', async function() { + it('npm', async function () { let blueprint = loadDefaultBlueprint(); expect(blueprint).to.deep.equal({ @@ -129,13 +120,11 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/ember-cli/ember-addon-output', codemodsSource: 'ember-addon-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--no-welcome' - ] + options: ['--no-welcome'] }); }); - it('yarn', async function() { + it('yarn', async function () { projectOptions.push('yarn'); let blueprint = loadDefaultBlueprint(); @@ -147,20 +136,17 @@ describe(_loadDefaultBlueprint, function() { outputRepo: 'https://github.com/ember-cli/ember-addon-output', codemodsSource: 'ember-addon-codemods-manifest@1', isBaseBlueprint: true, - options: [ - '--yarn', - '--no-welcome' - ] + options: ['--yarn', '--no-welcome'] }); }); }); - describe('glimmer', function() { - beforeEach(function() { + describe('glimmer', function () { + beforeEach(function () { projectOptions.push('glimmer'); }); - it('works', async function() { + it('works', async function () { let blueprint = loadDefaultBlueprint(); expect(blueprint).to.deep.equal({ diff --git a/test/integration/load-safe-blueprint-file-test.js b/test/integration/load-safe-blueprint-file-test.js index 848c55e2..f8709866 100644 --- a/test/integration/load-safe-blueprint-file-test.js +++ b/test/integration/load-safe-blueprint-file-test.js @@ -6,13 +6,14 @@ const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const loadSafeBlueprint = require('../../src/load-safe-blueprint'); const sinon = require('sinon'); -describe(loadSafeBlueprintFile, function() { - afterEach(function() { +describe(loadSafeBlueprintFile, function () { + afterEach(function () { sinon.restore(); }); - it('populates when missing', async function() { - let dir = 'test/fixtures/ember-cli-update-json/missing/ember-cli-update.json'; + it('populates when missing', async function () { + let dir = + 'test/fixtures/ember-cli-update-json/missing/ember-cli-update.json'; let emberCliUpdateJson = await loadSafeBlueprintFile(dir); @@ -22,7 +23,7 @@ describe(loadSafeBlueprintFile, function() { }); }); - it('populates when empty', async function() { + it('populates when empty', async function () { let dir = 'test/fixtures/ember-cli-update-json/empty/ember-cli-update.json'; let emberCliUpdateJson = await loadSafeBlueprintFile(dir); @@ -33,37 +34,45 @@ describe(loadSafeBlueprintFile, function() { }); }); - it('flattens packages', async function() { - let dir = 'test/fixtures/ember-cli-update-json/normal/ember-cli-update.json'; + it('flattens packages', async function () { + let dir = + 'test/fixtures/ember-cli-update-json/normal/ember-cli-update.json'; let emberCliUpdateJson = await loadSafeBlueprintFile(dir); expect(emberCliUpdateJson).to.deep.equal({ schemaVersion: '1.0.0', - blueprints: [loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - location: '../test-blueprint', - version: '0.0.1', - outputRepo: 'https://github.com/test/output-repo', - codemodsSource: 'test-codemods', - isBaseBlueprint: true - })] + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + location: '../test-blueprint', + version: '0.0.1', + outputRepo: 'https://github.com/test/output-repo', + codemodsSource: 'test-codemods', + isBaseBlueprint: true + }) + ] }); }); - it('throws with unexpected version', async function() { - let dir = 'test/fixtures/ember-cli-update-json/unexpected-version/ember-cli-update.json'; + it('throws with unexpected version', async function () { + let dir = + 'test/fixtures/ember-cli-update-json/unexpected-version/ember-cli-update.json'; let promise = loadSafeBlueprintFile(dir); - await expect(promise).to.eventually.be.rejectedWith('schemaVersion 255.0.0 is unexpectedly newer than the current 1.0.0.'); + await expect(promise).to.eventually.be.rejectedWith( + 'schemaVersion 255.0.0 is unexpectedly newer than the current 1.0.0.' + ); }); - it('logs a warning when updating schema version', async function() { + it('logs a warning when updating schema version', async function () { let dir = 'test/fixtures/ember-cli-update-json/old/ember-cli-update.json'; - let warn = sinon.stub(console, 'warn').withArgs('Updating schemaVersion from 0 to 1.0.0.'); + let warn = sinon + .stub(console, 'warn') + .withArgs('Updating schemaVersion from 0 to 1.0.0.'); let emberCliUpdateJson = await loadSafeBlueprintFile(dir); @@ -71,15 +80,17 @@ describe(loadSafeBlueprintFile, function() { expect(emberCliUpdateJson).to.deep.equal({ schemaVersion: '1.0.0', - blueprints: [loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - location: '../test-blueprint', - version: '0.0.1', - outputRepo: 'https://github.com/test/output-repo', - codemodsSource: 'test-codemods', - isBaseBlueprint: true - })] + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + location: '../test-blueprint', + version: '0.0.1', + outputRepo: 'https://github.com/test/output-repo', + codemodsSource: 'test-codemods', + isBaseBlueprint: true + }) + ] }); }); }); diff --git a/test/integration/load-safe-blueprint-test.js b/test/integration/load-safe-blueprint-test.js index f7f7a65f..bbc1abca 100644 --- a/test/integration/load-safe-blueprint-test.js +++ b/test/integration/load-safe-blueprint-test.js @@ -4,8 +4,8 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const loadSafeBlueprint = require('../../src/load-safe-blueprint'); -describe(loadSafeBlueprint, function() { - it('works', async function() { +describe(loadSafeBlueprint, function () { + it('works', async function () { let blueprint = loadSafeBlueprint({ foo: 'bar' }); @@ -16,7 +16,7 @@ describe(loadSafeBlueprint, function() { }); }); - it('doesn\'t remove existing options', async function() { + it("doesn't remove existing options", async function () { let blueprint = loadSafeBlueprint({ options: ['foo'] }); @@ -26,15 +26,12 @@ describe(loadSafeBlueprint, function() { }); }); - it('doesn\'t reorder existing options', async function() { + it("doesn't reorder existing options", async function () { let blueprint = loadSafeBlueprint({ foo: 'bar', options: ['foo'] }); - expect(Object.keys(blueprint)).to.deep.equal([ - 'foo', - 'options' - ]); + expect(Object.keys(blueprint)).to.deep.equal(['foo', 'options']); }); }); diff --git a/test/integration/overwrite-blueprint-files-test.js b/test/integration/overwrite-blueprint-files-test.js index b4962d03..7860f19b 100644 --- a/test/integration/overwrite-blueprint-files-test.js +++ b/test/integration/overwrite-blueprint-files-test.js @@ -2,9 +2,7 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); -const { - buildTmp -} = require('git-fixtures'); +const { buildTmp } = require('git-fixtures'); const overwriteBlueprintFiles = require('../../src/overwrite-blueprint-files'); const { spawn } = require('../../src/run'); const { initBlueprint } = require('../helpers/blueprint'); @@ -12,18 +10,19 @@ const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const sinon = require('sinon'); const { ember } = require('../../src/install-and-generate-blueprint'); -describe(overwriteBlueprintFiles, function() { +describe(overwriteBlueprintFiles, function () { this.timeout(90e3); - it('can install an addon with a default blueprint and no state file', async function() { + it('can install an addon with a default blueprint and no state file', async function () { let tmpPath = await buildTmp({ fixturesPath: 'test/fixtures/app/local' }); - let { - packageName, - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { packageName, location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/addon/legacy-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; let blueprintPath = await initBlueprint({ fixturesPath: 'test/fixtures/blueprint/addon/legacy', diff --git a/test/integration/parse-blueprint-package-test.js b/test/integration/parse-blueprint-package-test.js index 0453d482..73318d7c 100644 --- a/test/integration/parse-blueprint-package-test.js +++ b/test/integration/parse-blueprint-package-test.js @@ -7,8 +7,8 @@ const parseBlueprintPackage = require('../../src/parse-blueprint-package'); const { toPosixAbsolutePath } = parseBlueprintPackage; -describe(parseBlueprintPackage, function() { - it('detects local paths', async function() { +describe(parseBlueprintPackage, function () { + it('detects local paths', async function () { let packageName = '../fixtures/blueprint/app/local/v0.0.2'; let parsedPackage = await parseBlueprintPackage({ @@ -23,7 +23,7 @@ describe(parseBlueprintPackage, function() { }); }); - it('detects urls', async function() { + it('detects urls', async function () { let packageName = 'http://test-blueprint.com'; let parsedPackage = await parseBlueprintPackage({ @@ -37,7 +37,7 @@ describe(parseBlueprintPackage, function() { }); }); - it('detects npm packages', async function() { + it('detects npm packages', async function () { let packageName = 'test-blueprint'; let parsedPackage = await parseBlueprintPackage({ @@ -51,10 +51,13 @@ describe(parseBlueprintPackage, function() { }); }); - it('uses npm even if subdir match', async function() { + it('uses npm even if subdir match', async function () { let packageName = 'config'; - let cwd = path.resolve(__dirname, '../fixtures/blueprint/app/local-app/local/my-app'); + let cwd = path.resolve( + __dirname, + '../fixtures/blueprint/app/local-app/local/my-app' + ); expect(cwd).to.be.a.directory().and.include.subDirs([packageName]); @@ -70,8 +73,8 @@ describe(parseBlueprintPackage, function() { }); }); - describe(toPosixAbsolutePath, function() { - it('does Windows', function() { + describe(toPosixAbsolutePath, function () { + it('does Windows', function () { let before = 'C:\\foo\\bar'; let expected = '/c/foo/bar'; @@ -80,7 +83,7 @@ describe(parseBlueprintPackage, function() { expect(actual).to.equal(expected); }); - it('does Unix', function() { + it('does Unix', function () { let before = '/foo/bar'; let expected = '/foo/bar'; diff --git a/test/integration/reset-test.js b/test/integration/reset-test.js index cce11918..797ac66f 100644 --- a/test/integration/reset-test.js +++ b/test/integration/reset-test.js @@ -9,15 +9,13 @@ const { fixtureCompare: _fixtureCompare } = require('git-fixtures'); const reset = require('../../src/reset'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const sinon = require('sinon'); const inquirer = require('inquirer'); -describe(reset, function() { +describe(reset, function () { this.timeout(60e3); let tmpPath; @@ -51,9 +49,7 @@ describe(reset, function() { }); } - function fixtureCompare({ - mergeFixtures - }) { + function fixtureCompare({ mergeFixtures }) { let actual = tmpPath; let expected = mergeFixtures; @@ -64,25 +60,30 @@ describe(reset, function() { }); } - it('can reset a custom blueprint', async function() { - let { - location - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/reset/local/my-app/config/ember-cli-update.json')).blueprints[1]; + it('can reset a custom blueprint', async function () { + let { location } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/reset/local/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - version: to - } = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/reset/merge/my-app/config/ember-cli-update.json')).blueprints[1]; + let { version: to } = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/reset/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints[1]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/reset/local', commitMessage: 'my-app', blueprint: location, to, async beforeMerge() { await initBlueprint({ - fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/local'), + fixturesPath: path.resolve( + __dirname, + '../fixtures/blueprint/app/local' + ), resolvedFrom: tmpPath, relativeDir: location }); @@ -96,11 +97,8 @@ describe(reset, function() { assertNoStaged(status); }); - it('handles missing blueprint', async function() { - let { - stderr, - status - } = await merge({ + it('handles missing blueprint', async function () { + let { stderr, status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', blueprint: 'missing' @@ -111,10 +109,8 @@ describe(reset, function() { expect(stderr).to.equal('blueprint "missing" was not found'); }); - it('can reset the default blueprint without a state file', async function() { - let { - status - } = await merge({ + it('can reset the default blueprint without a state file', async function () { + let { status } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app', to: '2.11.1' @@ -129,17 +125,20 @@ describe(reset, function() { }); }); - it('can reset the default blueprint with a state file', async function() { - sinon.stub(inquirer, 'prompt').withArgs([{ - type: 'list', - message: 'Which blueprint would you like to reset?', - name: 'blueprint', - choices: [{ name: 'ember-cli' }] - }]).resolves({ blueprint: 'ember-cli' }); - - let { - status - } = await merge({ + it('can reset the default blueprint with a state file', async function () { + sinon + .stub(inquirer, 'prompt') + .withArgs([ + { + type: 'list', + message: 'Which blueprint would you like to reset?', + name: 'blueprint', + choices: [{ name: 'ember-cli' }] + } + ]) + .resolves({ blueprint: 'ember-cli' }); + + let { status } = await merge({ fixturesPath: 'test/fixtures/app/merge', commitMessage: 'my-app', to: '2.11.1' @@ -154,16 +153,18 @@ describe(reset, function() { }); }); - it('can reset a default blueprint by name', async function() { + it('can reset a default blueprint by name', async function () { let { packageName, name: blueprint, version: to - } = (await loadSafeBlueprintFile('test/fixtures/app/reset/my-app/config/ember-cli-update.json')).blueprints[0]; + } = ( + await loadSafeBlueprintFile( + 'test/fixtures/app/reset/my-app/config/ember-cli-update.json' + ) + ).blueprints[0]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/app/merge', commitMessage: 'my-app', packageName, diff --git a/test/integration/save-blueprint-file-test.js b/test/integration/save-blueprint-file-test.js index ba3e4e64..59163161 100644 --- a/test/integration/save-blueprint-file-test.js +++ b/test/integration/save-blueprint-file-test.js @@ -6,14 +6,14 @@ const path = require('path'); const { createTmpDir } = require('../../src/tmp'); const saveBlueprintFile = require('../../src/save-blueprint-file'); -describe(saveBlueprintFile, function() { +describe(saveBlueprintFile, function () { let tmpPath; - beforeEach(async function() { + beforeEach(async function () { tmpPath = await createTmpDir(); }); - it('works', async function() { + it('works', async function () { let emberCliUpdateJsonPath = path.join(tmpPath, 'ember-cli-update.json'); await saveBlueprintFile(emberCliUpdateJsonPath, { @@ -33,7 +33,10 @@ describe(saveBlueprintFile, function() { ] }); - expect(emberCliUpdateJsonPath).to.be.a.file() - .and.equal('test/fixtures/ember-cli-update-json/normal/ember-cli-update.json'); + expect(emberCliUpdateJsonPath) + .to.be.a.file() + .and.equal( + 'test/fixtures/ember-cli-update-json/normal/ember-cli-update.json' + ); }); }); diff --git a/test/integration/save-test.js b/test/integration/save-test.js index 6f945fd8..e0995f90 100644 --- a/test/integration/save-test.js +++ b/test/integration/save-test.js @@ -3,18 +3,13 @@ const path = require('path'); const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); -const { - buildTmp, - processExit -} = require('git-fixtures'); +const { buildTmp, processExit } = require('git-fixtures'); const { isGitClean } = require('git-diff-apply'); const save = require('../../src/save'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); -describe(save, function() { +describe(save, function () { this.timeout(5e3); let tmpPath; @@ -51,32 +46,27 @@ describe(save, function() { }); } - it('handles missing version', async function() { - let { - stderr - } = await merge({ + it('handles missing version', async function () { + let { stderr } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app' }); expect(await isGitClean({ cwd: tmpPath })).to.be.ok; - expect(stderr).to.equal('A custom blueprint cannot detect --from. You must supply it.'); + expect(stderr).to.equal( + 'A custom blueprint cannot detect --from. You must supply it.' + ); }); - it('works for custom blueprint with package name', async function() { - let { - packageName, - name, - version, - outputRepo, - codemodsSource, - options - } = (await loadSafeBlueprintFile('test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json')).blueprints[0]; + it('works for custom blueprint with package name', async function () { + let { packageName, name, version, outputRepo, codemodsSource, options } = ( + await loadSafeBlueprintFile( + 'test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ) + ).blueprints[0]; - let { - status - } = await merge({ + let { status } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app', packageName, @@ -89,7 +79,10 @@ describe(save, function() { assertNoStaged(status); - expect(path.join(tmpPath, 'config/ember-cli-update.json')).to.be.a.file() - .and.equal('test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json'); + expect(path.join(tmpPath, 'config/ember-cli-update.json')) + .to.be.a.file() + .and.equal( + 'test/fixtures/ember-cli-update-json/default/config/ember-cli-update.json' + ); }); }); diff --git a/test/integration/stats-test.js b/test/integration/stats-test.js index 9ee9c711..739b84d1 100644 --- a/test/integration/stats-test.js +++ b/test/integration/stats-test.js @@ -2,15 +2,10 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); -const { - buildTmp, - processExit -} = require('git-fixtures'); +const { buildTmp, processExit } = require('git-fixtures'); const { isGitClean } = require('git-diff-apply'); const stats = require('../../src/stats'); -const { - assertNoStaged -} = require('../helpers/assertions'); +const { assertNoStaged } = require('../helpers/assertions'); const { initBlueprint } = require('../helpers/blueprint'); const loadSafeBlueprintFile = require('../../src/load-safe-blueprint-file'); const utils = require('../../src/utils'); @@ -20,12 +15,12 @@ const { defaultAppBlueprintName } = require('../../src/constants'); -describe(stats, function() { +describe(stats, function () { this.timeout(30e3); let tmpPath; - afterEach(function() { + afterEach(function () { sinon.restore(); }); @@ -56,13 +51,9 @@ describe(stats, function() { }); } - it('works', async function() { + it('works', async function () { let [ - { - packageName: packageName1, - name: blueprintName1, - version: from1 - }, + { packageName: packageName1, name: blueprintName1, version: from1 }, { packageName: packageName2, name: blueprintName2, @@ -72,30 +63,31 @@ describe(stats, function() { codemodsSource, options } - ] = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints; - - sinon.stub(utils, 'getApplicableCodemods').withArgs({ - source: codemodsSource, - projectOptions: options, - packageJson: require('../fixtures/blueprint/app/local-app/local/my-app/package') - }).resolves({ - testCodemod1: {}, - testCodemod2: {} - }); - - let [ - { - version: to1 - }, - { - version: to2 - } - ] = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json')).blueprints; - - let { - result, - status - } = await merge({ + ] = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json' + ) + ).blueprints; + + sinon + .stub(utils, 'getApplicableCodemods') + .withArgs({ + source: codemodsSource, + projectOptions: options, + packageJson: require('../fixtures/blueprint/app/local-app/local/my-app/package') + }) + .resolves({ + testCodemod1: {}, + testCodemod2: {} + }); + + let [{ version: to1 }, { version: to2 }] = ( + await loadSafeBlueprintFile( + 'test/fixtures/blueprint/app/local-app/merge/my-app/config/ember-cli-update.json' + ) + ).blueprints; + + let { result, status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', async beforeMerge() { @@ -125,11 +117,8 @@ codemods source: ${codemodsSource} applicable codemods: testCodemod1, testCodemod2`); }); - it('handles missing blueprint', async function() { - let { - stderr, - status - } = await merge({ + it('handles missing blueprint', async function () { + let { stderr, status } = await merge({ fixturesPath: 'test/fixtures/blueprint/app/local-app/local', commitMessage: 'my-app', blueprint: 'missing' @@ -140,15 +129,13 @@ applicable codemods: testCodemod1, testCodemod2`); expect(stderr).to.equal('blueprint "missing" was not found'); }); - it('works for the default blueprint without a state file', async function() { - sinon.stub(utils, 'getVersions').withArgs('ember-cli').resolves([ - '2.11.1', - '3.15.0' - ]); + it('works for the default blueprint without a state file', async function () { + sinon + .stub(utils, 'getVersions') + .withArgs('ember-cli') + .resolves(['2.11.1', '3.15.0']); - let { - result - } = await merge({ + let { result } = await merge({ fixturesPath: 'test/fixtures/app/local', commitMessage: 'my-app' }); @@ -164,14 +151,10 @@ codemods source: ember-app-codemods-manifest@1 applicable codemods: `); }); - it('works for the default blueprint with a state file', async function() { - sinon.stub(utils, 'getVersions').withArgs('ember-cli').resolves([ - '3.15.0' - ]); + it('works for the default blueprint with a state file', async function () { + sinon.stub(utils, 'getVersions').withArgs('ember-cli').resolves(['3.15.0']); - let { - result - } = await merge({ + let { result } = await merge({ fixturesPath: 'test/fixtures/app/merge', commitMessage: 'my-app' }); @@ -187,14 +170,10 @@ codemods source: ember-app-codemods-manifest@1 applicable codemods: ember-modules-codemod, ember-qunit-codemod, ember-test-helpers-codemod, es5-getter-ember-codemod, notify-property-change, qunit-dom-codemod, deprecate-merge-codemod, deprecate-router-events-codemod, cp-property-codemod, cp-volatile-codemod, cp-property-map-codemod, ember-angle-brackets-codemod, ember-data-codemod`); }); - it('works for a default blueprint by name', async function() { - sinon.stub(utils, 'getVersions').withArgs('ember-cli').resolves([ - '3.15.0' - ]); + it('works for a default blueprint by name', async function () { + sinon.stub(utils, 'getVersions').withArgs('ember-cli').resolves(['3.15.0']); - let { - result - } = await merge({ + let { result } = await merge({ fixturesPath: 'test/fixtures/app/merge', commitMessage: 'my-app', packageName: defaultPackageName, diff --git a/test/unit/find-blueprint-test.js b/test/unit/find-blueprint-test.js index b12f82da..9058d580 100644 --- a/test/unit/find-blueprint-test.js +++ b/test/unit/find-blueprint-test.js @@ -4,10 +4,10 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const findBlueprint = require('../../src/find-blueprint'); -describe(findBlueprint, function() { +describe(findBlueprint, function () { let emberCliUpdateJson; - beforeEach(function() { + beforeEach(function () { emberCliUpdateJson = { blueprints: [ { @@ -29,7 +29,7 @@ describe(findBlueprint, function() { }; }); - it('finds blueprint', function() { + it('finds blueprint', function () { let packageName = 'test-blueprint'; let name = 'test-blueprint'; @@ -46,7 +46,7 @@ describe(findBlueprint, function() { expect(actual).to.equal(expected); }); - it('package mismatch', function() { + it('package mismatch', function () { let packageName = 'test-blueprint-3'; let name = 'test-blueprint'; @@ -55,7 +55,7 @@ describe(findBlueprint, function() { expect(actual).to.be.undefined; }); - it('blueprint mismatch', function() { + it('blueprint mismatch', function () { let packageName = 'test-blueprint'; let name = 'test-blueprint-3'; diff --git a/test/unit/get-default-blueprint-name-override-test.js b/test/unit/get-default-blueprint-name-override-test.js index a2d5da48..df6c5d8f 100644 --- a/test/unit/get-default-blueprint-name-override-test.js +++ b/test/unit/get-default-blueprint-name-override-test.js @@ -11,54 +11,64 @@ const pacote = require('pacote'); const cwd = 'a/made/up/path'; const packageNameOrPath = '../a-package-name'; const defaultBlueprint = 'not-the-same-name'; -const localPackageJsonPath = path.join(path.resolve(cwd, packageNameOrPath), 'package.json'); +const localPackageJsonPath = path.join( + path.resolve(cwd, packageNameOrPath), + 'package.json' +); -describe(getBlueprintNameOverride, function() { +describe(getBlueprintNameOverride, function () { let pathExistsStub; let readFileStub; let manifestStub; - beforeEach(function() { + beforeEach(function () { pathExistsStub = sinon.stub(fs, 'pathExists'); readFileStub = sinon.stub(fs, 'readFile'); manifestStub = sinon.stub(pacote, 'manifest'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - it('returns default blueprint override name if it exists', async function() { + it('returns default blueprint override name if it exists', async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(true); - readFileStub.withArgs(localPackageJsonPath).resolves(JSON.stringify({ - name: packageNameOrPath, - 'ember-addon': { - defaultBlueprint - } - })); + readFileStub.withArgs(localPackageJsonPath).resolves( + JSON.stringify({ + name: packageNameOrPath, + 'ember-addon': { + defaultBlueprint + } + }) + ); - let defaultBlueprintOverride = await getBlueprintNameOverride(packageNameOrPath, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + packageNameOrPath, + cwd + ); expect(defaultBlueprintOverride).to.equal(defaultBlueprint); }); - it('doesn\'t use NPM if found locally', async function() { + it("doesn't use NPM if found locally", async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(true); - readFileStub.withArgs(localPackageJsonPath).resolves(JSON.stringify({ - name: packageNameOrPath, - 'ember-addon': { - defaultBlueprint - } - })); + readFileStub.withArgs(localPackageJsonPath).resolves( + JSON.stringify({ + name: packageNameOrPath, + 'ember-addon': { + defaultBlueprint + } + }) + ); await getBlueprintNameOverride(packageNameOrPath, cwd); expect(manifestStub).to.not.have.been.called; }); - it('uses NPM if not found locally', async function() { + it('uses NPM if not found locally', async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(false); manifestStub.withArgs(packageNameOrPath).resolves({ @@ -68,12 +78,15 @@ describe(getBlueprintNameOverride, function() { } }); - let defaultBlueprintOverride = await getBlueprintNameOverride(packageNameOrPath, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + packageNameOrPath, + cwd + ); expect(defaultBlueprintOverride).to.equal(defaultBlueprint); }); - it('doesn\'t read local file if using NPM', async function() { + it("doesn't read local file if using NPM", async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(false); manifestStub.withArgs(packageNameOrPath).resolves({ @@ -88,44 +101,57 @@ describe(getBlueprintNameOverride, function() { expect(readFileStub).to.not.have.been.called; }); - it('null if ember-addon does not exist in package.json', async function() { + it('null if ember-addon does not exist in package.json', async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(true); - readFileStub.withArgs(localPackageJsonPath).resolves(JSON.stringify({ - name: packageNameOrPath - })); + readFileStub.withArgs(localPackageJsonPath).resolves( + JSON.stringify({ + name: packageNameOrPath + }) + ); - let defaultBlueprintOverride = await getBlueprintNameOverride(packageNameOrPath, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + packageNameOrPath, + cwd + ); expect(defaultBlueprintOverride).to.be.null; }); - it('null if defaultBlueprint does not exist in ember-addon', async function() { + it('null if defaultBlueprint does not exist in ember-addon', async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(true); - readFileStub.withArgs(localPackageJsonPath).resolves(JSON.stringify({ - name: packageNameOrPath, - 'ember-addon': {} - })); + readFileStub.withArgs(localPackageJsonPath).resolves( + JSON.stringify({ + name: packageNameOrPath, + 'ember-addon': {} + }) + ); - let defaultBlueprintOverride = await getBlueprintNameOverride(packageNameOrPath, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + packageNameOrPath, + cwd + ); expect(defaultBlueprintOverride).to.be.null; }); - it('missing NPM package returns null', async function() { + it('missing NPM package returns null', async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(false); manifestStub.withArgs(packageNameOrPath).rejects({ statusCode: 404 }); - let defaultBlueprintOverride = await getBlueprintNameOverride(packageNameOrPath, cwd); + let defaultBlueprintOverride = await getBlueprintNameOverride( + packageNameOrPath, + cwd + ); expect(defaultBlueprintOverride).to.be.null; }); - it('doesn\'t swallow all NPM errors', async function() { + it("doesn't swallow all NPM errors", async function () { pathExistsStub.withArgs(localPackageJsonPath).resolves(false); let err = { diff --git a/test/unit/get-package-name-test.js b/test/unit/get-package-name-test.js index fb71baac..78963cce 100644 --- a/test/unit/get-package-name-test.js +++ b/test/unit/get-package-name-test.js @@ -4,16 +4,16 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const getPackageName = require('../../src/get-package-name'); -describe(getPackageName, function() { - it('gets app package', function() { +describe(getPackageName, function () { + it('gets app package', function () { expect(getPackageName(['app'])).to.equal('ember-cli'); }); - it('gets addon package', function() { + it('gets addon package', function () { expect(getPackageName(['addon'])).to.equal('ember-cli'); }); - it('gets glimmer package', function() { + it('gets glimmer package', function () { expect(getPackageName(['glimmer'])).to.equal('@glimmer/blueprint'); }); }); diff --git a/test/unit/get-package-version-test.js b/test/unit/get-package-version-test.js index 4e9d3b1f..79653567 100644 --- a/test/unit/get-package-version-test.js +++ b/test/unit/get-package-version-test.js @@ -4,8 +4,8 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const getPackageVersion = require('../../src/get-package-version'); -describe(getPackageVersion, function() { - it('throws if no packages', function() { +describe(getPackageVersion, function () { + it('throws if no packages', function () { let packageJson = {}; expect(() => { @@ -13,7 +13,7 @@ describe(getPackageVersion, function() { }).to.throw('Ember CLI blueprint version could not be determined'); }); - it('throws if no package', function() { + it('throws if no package', function () { let packageJson = { devDependencies: {} }; @@ -23,27 +23,31 @@ describe(getPackageVersion, function() { }).to.throw('Ember CLI blueprint version could not be determined'); }); - it('gets version as dependency', function() { + it('gets version as dependency', function () { let packageJson = { dependencies: { 'test-package-name': '2.11' } }; - expect(getPackageVersion(packageJson, 'test-package-name')).to.equal('2.11'); + expect(getPackageVersion(packageJson, 'test-package-name')).to.equal( + '2.11' + ); }); - it('gets version as devDependency', function() { + it('gets version as devDependency', function () { let packageJson = { devDependencies: { 'test-package-name': '2.11' } }; - expect(getPackageVersion(packageJson, 'test-package-name')).to.equal('2.11'); + expect(getPackageVersion(packageJson, 'test-package-name')).to.equal( + '2.11' + ); }); - it('doesn\'t throw if empty string', function() { + it("doesn't throw if empty string", function () { let packageJson = { dependencies: { 'test-package-name': '' diff --git a/test/unit/get-project-options-test.js b/test/unit/get-project-options-test.js index e6b6d937..a58ff713 100644 --- a/test/unit/get-project-options-test.js +++ b/test/unit/get-project-options-test.js @@ -5,13 +5,13 @@ const { expect } = require('../helpers/chai'); const path = require('path'); const _getProjectOptions = require('../../src/get-project-options'); -describe(_getProjectOptions, function() { +describe(_getProjectOptions, function () { let packageJson; let blueprint; setUpCwdReset(); - beforeEach(function() { + beforeEach(function () { packageJson = {}; blueprint = { @@ -24,13 +24,14 @@ describe(_getProjectOptions, function() { return _getProjectOptions(packageJson, blueprint); } - it('throws if not found', async function() { - await expect(getProjectOptions()) - .to.eventually.be.rejectedWith('Ember CLI project type could not be determined'); + it('throws if not found', async function () { + await expect(getProjectOptions()).to.eventually.be.rejectedWith( + 'Ember CLI project type could not be determined' + ); }); - describe('app', function() { - it('detects ember app with ember-cli as a devDependency', async function() { + describe('app', function () { + it('detects ember app with ember-cli as a devDependency', async function () { packageJson = { devDependencies: { 'ember-cli': '2.11' @@ -40,7 +41,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['app']); }); - it('detects ember app with ember-cli as a dependency', async function() { + it('detects ember app with ember-cli as a dependency', async function () { packageJson = { dependencies: { 'ember-cli': '2.11' @@ -50,7 +51,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['app']); }); - it('detects ember app with ember-cli as an empty string', async function() { + it('detects ember app with ember-cli as an empty string', async function () { packageJson = { devDependencies: { 'ember-cli': '' @@ -60,7 +61,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['app']); }); - it('detects welcome option', async function() { + it('detects welcome option', async function () { packageJson = { devDependencies: { 'ember-cli': '2.11', @@ -71,7 +72,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['app', 'welcome']); }); - it('detects yarn option', async function() { + it('detects yarn option', async function () { packageJson = { devDependencies: { 'ember-cli': '2.11' @@ -84,12 +85,10 @@ describe(_getProjectOptions, function() { }); }); - describe('addon', function() { - it('detects ember addon with ember-cli as a devDependency', async function() { + describe('addon', function () { + it('detects ember addon with ember-cli as a devDependency', async function () { packageJson = { - keywords: [ - 'ember-addon' - ], + keywords: ['ember-addon'], devDependencies: { 'ember-cli': '2.11' } @@ -98,11 +97,9 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['addon']); }); - it('detects ember addon with ember-cli as a dependency', async function() { + it('detects ember addon with ember-cli as a dependency', async function () { packageJson = { - keywords: [ - 'ember-addon' - ], + keywords: ['ember-addon'], dependencies: { 'ember-cli': '2.11' } @@ -111,11 +108,9 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['addon']); }); - it('detects ember addon with ember-cli as an empty string', async function() { + it('detects ember addon with ember-cli as an empty string', async function () { packageJson = { - keywords: [ - 'ember-addon' - ], + keywords: ['ember-addon'], devDependencies: { 'ember-cli': '' } @@ -124,11 +119,9 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['addon']); }); - it('doesn\'t detect welcome option', async function() { + it("doesn't detect welcome option", async function () { packageJson = { - keywords: [ - 'ember-addon' - ], + keywords: ['ember-addon'], devDependencies: { 'ember-cli': '2.11', 'ember-welcome-page': '' @@ -138,11 +131,9 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['addon']); }); - it('detects yarn option', async function() { + it('detects yarn option', async function () { packageJson = { - keywords: [ - 'ember-addon' - ], + keywords: ['ember-addon'], devDependencies: { 'ember-cli': '2.11' } @@ -154,8 +145,8 @@ describe(_getProjectOptions, function() { }); }); - describe('glimmer', function() { - it('detects glimmer app with glimmer as a devDependency', async function() { + describe('glimmer', function () { + it('detects glimmer app with glimmer as a devDependency', async function () { packageJson = { devDependencies: { '@glimmer/blueprint': '0.3' @@ -165,7 +156,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['glimmer']); }); - it('detects glimmer app with glimmer as a dependency', async function() { + it('detects glimmer app with glimmer as a dependency', async function () { packageJson = { dependencies: { '@glimmer/blueprint': '0.3' @@ -175,7 +166,7 @@ describe(_getProjectOptions, function() { expect(await getProjectOptions()).to.deep.equal(['glimmer']); }); - it('detects glimmer app with glimmer as an empty string', async function() { + it('detects glimmer app with glimmer as an empty string', async function () { packageJson = { devDependencies: { '@glimmer/blueprint': '' @@ -186,13 +177,13 @@ describe(_getProjectOptions, function() { }); }); - it('detects custom blueprint', async function() { + it('detects custom blueprint', async function () { blueprint = {}; expect(await getProjectOptions()).to.deep.equal(['blueprint']); }); - it('can run without blueprint', async function() { + it('can run without blueprint', async function () { packageJson = { devDependencies: { 'ember-cli': '2.11' diff --git a/test/unit/get-project-version-test.js b/test/unit/get-project-version-test.js index 9db535d5..3b407d18 100644 --- a/test/unit/get-project-version-test.js +++ b/test/unit/get-project-version-test.js @@ -4,24 +4,14 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const getProjectVersion = require('../../src/get-project-version'); -describe(getProjectVersion, function() { - it('throws if glimmer and < 0.6.3', function() { - expect(() => getProjectVersion( - '0.3', - [ - '0.3.1' - ], - ['glimmer'] - )).to.throw('version cannot be determined'); +describe(getProjectVersion, function () { + it('throws if glimmer and < 0.6.3', function () { + expect(() => getProjectVersion('0.3', ['0.3.1'], ['glimmer'])).to.throw( + 'version cannot be determined' + ); }); - it('doesn\'t throw if glimmer and >= 0.6.3', function() { - expect(getProjectVersion( - '0.6', - [ - '0.6.3' - ], - ['glimmer'] - )).to.equal('0.6.3'); + it("doesn't throw if glimmer and >= 0.6.3", function () { + expect(getProjectVersion('0.6', ['0.6.3'], ['glimmer'])).to.equal('0.6.3'); }); }); diff --git a/test/unit/get-remote-url-test.js b/test/unit/get-remote-url-test.js index 5e8a4566..20737e1c 100644 --- a/test/unit/get-remote-url-test.js +++ b/test/unit/get-remote-url-test.js @@ -4,20 +4,20 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const getRemoteUrl = require('../../src/get-remote-url'); -describe(getRemoteUrl, function() { - it('gets remote url for ember app', function() { +describe(getRemoteUrl, function () { + it('gets remote url for ember app', function () { expect(getRemoteUrl(['app'])).to.equal( 'https://github.com/ember-cli/ember-new-output' ); }); - it('gets remote url for ember addon', function() { + it('gets remote url for ember addon', function () { expect(getRemoteUrl(['addon'])).to.equal( 'https://github.com/ember-cli/ember-addon-output' ); }); - it('gets remote url for glimmer app', function() { + it('gets remote url for glimmer app', function () { expect(getRemoteUrl(['glimmer'])).to.equal( 'https://github.com/glimmerjs/glimmer-blueprint-output' ); diff --git a/test/unit/get-start-and-end-commands-test.js b/test/unit/get-start-and-end-commands-test.js index 6dc9f25d..f221437e 100644 --- a/test/unit/get-start-and-end-commands-test.js +++ b/test/unit/get-start-and-end-commands-test.js @@ -9,9 +9,7 @@ const utils = require('../../src/utils'); const loadSafeBlueprint = require('../../src/load-safe-blueprint'); const loadDefaultBlueprint = require('../../src/load-default-blueprint'); -const { - getArgs: _getArgs -} = _getStartAndEndCommands; +const { getArgs: _getArgs } = _getStartAndEndCommands; const projectName = 'my-custom-project'; const startVersion = '0.0.1'; @@ -29,50 +27,65 @@ const baseBlueprint = loadDefaultBlueprint([], baseVersion); const defaultStartBlueprint = loadDefaultBlueprint([], startVersion); const defaultEndBlueprint = loadDefaultBlueprint([], endVersion); -describe(_getStartAndEndCommands, function() { +describe(_getStartAndEndCommands, function () { let npxStub; let spawnStub; let readdirStub; let installAddonBlueprintStub; let appendNodeModulesIgnoreStub; - beforeEach(function() { + beforeEach(function () { npxStub = sinon.stub(_getStartAndEndCommands, 'npx').returns('test npx'); - spawnStub = sinon.stub(_getStartAndEndCommands, 'spawn').returns('test spawn'); + spawnStub = sinon + .stub(_getStartAndEndCommands, 'spawn') + .returns('test spawn'); readdirStub = sinon.stub(utils, 'readdir').resolves(['foo']); - installAddonBlueprintStub = sinon.stub(_getStartAndEndCommands, 'installAddonBlueprint').resolves(); - appendNodeModulesIgnoreStub = sinon.stub(_getStartAndEndCommands, 'appendNodeModulesIgnore').resolves(); + installAddonBlueprintStub = sinon + .stub(_getStartAndEndCommands, 'installAddonBlueprint') + .resolves(); + appendNodeModulesIgnoreStub = sinon + .stub(_getStartAndEndCommands, 'appendNodeModulesIgnore') + .resolves(); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); function getStartAndEndCommands(options) { - return _getStartAndEndCommands(Object.assign({ - packageJson: { name: projectName }, - startBlueprint: defaultStartBlueprint, - endBlueprint: defaultEndBlueprint - }, options)); + return _getStartAndEndCommands( + Object.assign( + { + packageJson: { name: projectName }, + startBlueprint: defaultStartBlueprint, + endBlueprint: defaultEndBlueprint + }, + options + ) + ); } - it('throws if base blueprint is not marked as such', function() { - let f = () => getStartAndEndCommands({ - baseBlueprint: {} - }); + it('throws if base blueprint is not marked as such', function () { + let f = () => + getStartAndEndCommands({ + baseBlueprint: {} + }); - expect(f).to.throw('The intended base blueprint is not actually a base blueprint.'); + expect(f).to.throw( + 'The intended base blueprint is not actually a base blueprint.' + ); }); - it('throws if two layers of base blueprints', function() { - let f = () => getStartAndEndCommands({ - baseBlueprint - }); + it('throws if two layers of base blueprints', function () { + let f = () => + getStartAndEndCommands({ + baseBlueprint + }); expect(f).to.throw('You supplied two layers of base blueprints.'); }); - it('returns an options object', function() { + it('returns an options object', function () { let options = getStartAndEndCommands(); expect(options.createProjectFromCache).to.be.a('function'); @@ -98,7 +111,7 @@ describe(_getStartAndEndCommands, function() { }); }); - it('can create a project from cache', async function() { + it('can create a project from cache', async function () { let { createProjectFromCache } = getStartAndEndCommands(); let createProject = createProjectFromCache({ @@ -109,30 +122,33 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-blueprint'] }); expect(await createProject(cwd)).to.equal(projectRoot); - expect(spawnStub.args).to.deep.equal([[ - 'node', + expect(spawnStub.args).to.deep.equal([ [ - path.normalize(`${packageRoot}/bin/ember`), - 'new', - projectName, - '--skip-git', - '--skip-npm', - '-b', - 'app' - ], - { - cwd - } - ]]); + 'node', + [ + path.normalize(`${packageRoot}/bin/ember`), + 'new', + projectName, + '--skip-git', + '--skip-npm', + '-b', + 'app' + ], + { + cwd + } + ] + ]); }); - it('can create a project from remote', async function() { + it('can create a project from remote', async function () { let { createProjectFromRemote } = getStartAndEndCommands(); let createProject = createProjectFromRemote({ @@ -144,25 +160,27 @@ describe(_getStartAndEndCommands, function() { expect(await createProject(cwd)).to.equal(projectRoot); - expect(npxStub.args).to.deep.equal([[ + expect(npxStub.args).to.deep.equal([ [ - '-p', - `${packageName}@${packageVersion}`, - commandName, - 'new', - projectName, - '--skip-git', - '--skip-npm', - '-b', - 'app' - ], - { - cwd - } - ]]); + [ + '-p', + `${packageName}@${packageVersion}`, + commandName, + 'new', + projectName, + '--skip-git', + '--skip-npm', + '-b', + 'app' + ], + { + cwd + } + ] + ]); }); - it('can create a project without a blueprint', async function() { + it('can create a project without a blueprint', async function () { let { createProjectFromRemote } = getStartAndEndCommands(); let createProject = createProjectFromRemote({ @@ -174,8 +192,8 @@ describe(_getStartAndEndCommands, function() { expect(npxStub).to.not.be.called; }); - describe('custom blueprint', function() { - it('returns an options object - base default', async function() { + describe('custom blueprint', function () { + it('returns an options object - base default', async function () { let options = getStartAndEndCommands({ baseBlueprint, startBlueprint: { @@ -217,7 +235,7 @@ describe(_getStartAndEndCommands, function() { }); }); - it('returns an options object - base custom', async function() { + it('returns an options object - base custom', async function () { let options = getStartAndEndCommands({ baseBlueprint: { version: baseVersion, @@ -268,7 +286,7 @@ describe(_getStartAndEndCommands, function() { }); }); - it('can create a project from cache', async function() { + it('can create a project from cache', async function () { let { createProjectFromCache } = getStartAndEndCommands(); let createProject = createProjectFromCache({ @@ -282,36 +300,43 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-blueprint'] }); expect(await createProject(cwd)).to.equal(projectRoot); - expect(spawnStub.args).to.deep.equal([[ - 'node', + expect(spawnStub.args).to.deep.equal([ [ - path.normalize(`${packageRoot}/bin/ember`), - 'new', - projectName, - '--skip-git', - '--skip-npm', - '-b', - blueprintPath - ], - { - cwd - } - ]]); + 'node', + [ + path.normalize(`${packageRoot}/bin/ember`), + 'new', + projectName, + '--skip-git', + '--skip-npm', + '-b', + blueprintPath + ], + { + cwd + } + ] + ]); expect(installAddonBlueprintStub).to.not.be.called; - expect(appendNodeModulesIgnoreStub.args).to.deep.equal([[{ - projectRoot - }]]); + expect(appendNodeModulesIgnoreStub.args).to.deep.equal([ + [ + { + projectRoot + } + ] + ]); }); - it('can create a project from remote', async function() { + it('can create a project from remote', async function () { let { createProjectFromRemote } = getStartAndEndCommands(); let createProject = createProjectFromRemote({ @@ -324,35 +349,42 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-blueprint'] }); expect(await createProject(cwd)).to.equal(projectRoot); - expect(npxStub.args).to.deep.equal([[ + expect(npxStub.args).to.deep.equal([ [ - `${packageName}@latest`, - 'new', - projectName, - '--skip-git', - '--skip-npm', - '-b', - blueprintPath - ], - { - cwd - } - ]]); + [ + `${packageName}@latest`, + 'new', + projectName, + '--skip-git', + '--skip-npm', + '-b', + blueprintPath + ], + { + cwd + } + ] + ]); expect(installAddonBlueprintStub).to.not.be.called; - expect(appendNodeModulesIgnoreStub.args).to.deep.equal([[{ - projectRoot - }]]); + expect(appendNodeModulesIgnoreStub.args).to.deep.equal([ + [ + { + projectRoot + } + ] + ]); }); - it('can install an addon blueprint from cache', async function() { + it('can install an addon blueprint from cache', async function () { let { createProjectFromCache } = getStartAndEndCommands(); readdirStub.resolves([]); @@ -368,7 +400,8 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-addon'] }); @@ -393,21 +426,29 @@ describe(_getStartAndEndCommands, function() { ] ]); - expect(installAddonBlueprintStub.args).to.deep.equal([[{ - projectRoot, - blueprint: { - path: blueprintPath, - options: [] - }, - packageManager: 'npm' - }]]); + expect(installAddonBlueprintStub.args).to.deep.equal([ + [ + { + projectRoot, + blueprint: { + path: blueprintPath, + options: [] + }, + packageManager: 'npm' + } + ] + ]); - expect(appendNodeModulesIgnoreStub.args).to.deep.equal([[{ - projectRoot - }]]); + expect(appendNodeModulesIgnoreStub.args).to.deep.equal([ + [ + { + projectRoot + } + ] + ]); }); - it('can install an addon blueprint from remote', async function() { + it('can install an addon blueprint from remote', async function () { let { createProjectFromRemote } = getStartAndEndCommands(); readdirStub.resolves([]); @@ -422,7 +463,8 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-addon'] }); @@ -448,21 +490,29 @@ describe(_getStartAndEndCommands, function() { ] ]); - expect(installAddonBlueprintStub.args).to.deep.equal([[{ - projectRoot, - blueprint: { - path: blueprintPath, - options: [] - }, - packageManager: 'npm' - }]]); + expect(installAddonBlueprintStub.args).to.deep.equal([ + [ + { + projectRoot, + blueprint: { + path: blueprintPath, + options: [] + }, + packageManager: 'npm' + } + ] + ]); - expect(appendNodeModulesIgnoreStub.args).to.deep.equal([[{ - projectRoot - }]]); + expect(appendNodeModulesIgnoreStub.args).to.deep.equal([ + [ + { + projectRoot + } + ] + ]); }); - it('falls back to safe project name if invalid', async function() { + it('falls back to safe project name if invalid', async function () { let { createProjectFromRemote } = getStartAndEndCommands(); readdirStub.resolves([]); @@ -477,7 +527,8 @@ describe(_getStartAndEndCommands, function() { } }); - sinon.stub(utils, 'require') + sinon + .stub(utils, 'require') .withArgs(path.join(blueprintPath, 'package')) .returns({ keywords: ['ember-addon'] }); @@ -503,23 +554,31 @@ describe(_getStartAndEndCommands, function() { } ]); - expect(installAddonBlueprintStub.args).to.deep.equal([[{ - projectRoot: path.join(cwd, 'my-project'), - blueprint: { - path: blueprintPath, - options: [] - }, - packageManager: 'npm' - }]]); + expect(installAddonBlueprintStub.args).to.deep.equal([ + [ + { + projectRoot: path.join(cwd, 'my-project'), + blueprint: { + path: blueprintPath, + options: [] + }, + packageManager: 'npm' + } + ] + ]); - expect(appendNodeModulesIgnoreStub.args).to.deep.equal([[{ - projectRoot: path.join(cwd, 'my-project') - }]]); + expect(appendNodeModulesIgnoreStub.args).to.deep.equal([ + [ + { + projectRoot: path.join(cwd, 'my-project') + } + ] + ]); }); }); - describe('init blueprint', function() { - it('returns an options object - default', function() { + describe('init blueprint', function () { + it('returns an options object - default', function () { let options = getStartAndEndCommands({ startBlueprint: null }); @@ -547,7 +606,7 @@ describe(_getStartAndEndCommands, function() { }); }); - it('returns an options object - custom', async function() { + it('returns an options object - custom', async function () { let options = getStartAndEndCommands({ baseBlueprint, startBlueprint: null, @@ -584,7 +643,7 @@ describe(_getStartAndEndCommands, function() { }); }); - describe(_getArgs, function() { + describe(_getArgs, function () { function getArgs(options) { return _getArgs({ projectName, @@ -593,7 +652,7 @@ describe(_getStartAndEndCommands, function() { }); } - it('works for default app', function() { + it('works for default app', function () { let blueprint = loadDefaultBlueprint(['welcome']); let args = getArgs({ @@ -610,7 +669,7 @@ describe(_getStartAndEndCommands, function() { ]); }); - it('works for default addon', function() { + it('works for default addon', function () { let blueprint = loadDefaultBlueprint(['addon']); let args = getArgs({ @@ -628,7 +687,7 @@ describe(_getStartAndEndCommands, function() { ]); }); - it('works for scoped project', function() { + it('works for scoped project', function () { let blueprint = loadDefaultBlueprint(['welcome']); let args = getArgs({ @@ -647,7 +706,7 @@ describe(_getStartAndEndCommands, function() { ]); }); - it('works for custom blueprint', function() { + it('works for custom blueprint', function () { let blueprint = loadSafeBlueprint({ path: '/path/to/my-blueprint' }); @@ -666,13 +725,10 @@ describe(_getStartAndEndCommands, function() { ]); }); - it('handles options', function() { + it('handles options', function () { let blueprint = { ...loadDefaultBlueprint(['welcome']), - options: [ - '--my-option-1', - '--my-option-2' - ] + options: ['--my-option-1', '--my-option-2'] }; let args = getArgs({ diff --git a/test/unit/install-and-generate-blueprint-test.js b/test/unit/install-and-generate-blueprint-test.js index be84d566..8d7d9a4a 100644 --- a/test/unit/install-and-generate-blueprint-test.js +++ b/test/unit/install-and-generate-blueprint-test.js @@ -6,41 +6,47 @@ const installAndGenerateBlueprint = require('../../src/install-and-generate-blue const { resolvePackageName } = installAndGenerateBlueprint; const sinon = require('sinon'); -describe(installAndGenerateBlueprint, function() { - describe(resolvePackageName, function() { - it('addonNameOverride takes precedence', function() { +describe(installAndGenerateBlueprint, function () { + describe(resolvePackageName, function () { + it('addonNameOverride takes precedence', function () { let result = resolvePackageName('hello-world'); expect(result).to.equal('hello-world'); }); - it('addonNameOverride with version takes precedence', function() { + it('addonNameOverride with version takes precedence', function () { let result = resolvePackageName('hello-world', '', '1.2.3'); expect(result).to.equal('hello-world@1.2.3'); }); - it('blueprint path is returned if override not passed', function() { + it('blueprint path is returned if override not passed', function () { let result = resolvePackageName('', 'path/to/blueprint'); expect(result).to.equal('path/to/blueprint'); }); - it('package name with version is returned', function() { + it('package name with version is returned', function () { let result = resolvePackageName('', '', '1.2.3', 'package-name'); expect(result).to.equal('package-name@1.2.3'); }); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - it('the expected params are passed for blueprint', async function() { - let stubbedSpawn = sinon.stub(installAndGenerateBlueprint, 'spawn').resolves(); - let stubbedEmber = sinon.stub(installAndGenerateBlueprint, 'ember').resolves(); - sinon.stub(installAndGenerateBlueprint, 'resolvePackageName').returns('hello-world'); + it('the expected params are passed for blueprint', async function () { + let stubbedSpawn = sinon + .stub(installAndGenerateBlueprint, 'spawn') + .resolves(); + let stubbedEmber = sinon + .stub(installAndGenerateBlueprint, 'ember') + .resolves(); + sinon + .stub(installAndGenerateBlueprint, 'resolvePackageName') + .returns('hello-world'); await installAndGenerateBlueprint({ cwd: 'fake/path', @@ -54,14 +60,25 @@ describe(installAndGenerateBlueprint, function() { }); expect(stubbedSpawn.getCall(0).args[0]).to.equal('yarn'); - expect(stubbedSpawn.getCall(0).args[1]).to.include.members(['add', '--save-dev', 'hello-world']); - expect(stubbedEmber.getCall(0).args[0]).to.include.members(['g', 'custom-blueprint']); + expect(stubbedSpawn.getCall(0).args[1]).to.include.members([ + 'add', + '--save-dev', + 'hello-world' + ]); + expect(stubbedEmber.getCall(0).args[0]).to.include.members([ + 'g', + 'custom-blueprint' + ]); }); - it('blueprint options were used to generate blueprint', async function() { + it('blueprint options were used to generate blueprint', async function () { sinon.stub(installAndGenerateBlueprint, 'spawn').resolves(); - let stubbedEmber = sinon.stub(installAndGenerateBlueprint, 'ember').resolves(); - sinon.stub(installAndGenerateBlueprint, 'resolvePackageName').returns('hello-world'); + let stubbedEmber = sinon + .stub(installAndGenerateBlueprint, 'ember') + .resolves(); + sinon + .stub(installAndGenerateBlueprint, 'resolvePackageName') + .returns('hello-world'); await installAndGenerateBlueprint({ cwd: 'fake/path', @@ -74,6 +91,13 @@ describe(installAndGenerateBlueprint, function() { packageManager: 'yarn' }); - expect(stubbedEmber.getCall(0).args[0]).to.include.members(['g', 'custom-blueprint', '--hello', 'world', '--another', 'option']); + expect(stubbedEmber.getCall(0).args[0]).to.include.members([ + 'g', + 'custom-blueprint', + '--hello', + 'world', + '--another', + 'option' + ]); }); }); diff --git a/test/unit/is-default-blueprint-test.js b/test/unit/is-default-blueprint-test.js index 9f91ed47..3330e33a 100644 --- a/test/unit/is-default-blueprint-test.js +++ b/test/unit/is-default-blueprint-test.js @@ -10,32 +10,40 @@ const { glimmerPackageName } = require('../../src/constants'); -describe(isDefaultBlueprint, function() { - it('detects default app blueprint', function() { - expect(isDefaultBlueprint({ - packageName: defaultPackageName, - name: defaultAppBlueprintName - })).to.be.true; +describe(isDefaultBlueprint, function () { + it('detects default app blueprint', function () { + expect( + isDefaultBlueprint({ + packageName: defaultPackageName, + name: defaultAppBlueprintName + }) + ).to.be.true; }); - it('detects default addon blueprint', function() { - expect(isDefaultBlueprint({ - packageName: defaultPackageName, - name: defaultAddonBlueprintName - })).to.be.true; + it('detects default addon blueprint', function () { + expect( + isDefaultBlueprint({ + packageName: defaultPackageName, + name: defaultAddonBlueprintName + }) + ).to.be.true; }); - it('detects glimmer blueprint', function() { - expect(isDefaultBlueprint({ - packageName: glimmerPackageName, - name: glimmerPackageName - })).to.be.true; + it('detects glimmer blueprint', function () { + expect( + isDefaultBlueprint({ + packageName: glimmerPackageName, + name: glimmerPackageName + }) + ).to.be.true; }); - it('detects custom blueprint', function() { - expect(isDefaultBlueprint({ - packageName: defaultPackageName, - name: 'custom-blueprint' - })).to.be.false; + it('detects custom blueprint', function () { + expect( + isDefaultBlueprint({ + packageName: defaultPackageName, + name: 'custom-blueprint' + }) + ).to.be.false; }); }); diff --git a/test/unit/load-default-blueprint-from-disk-test.js b/test/unit/load-default-blueprint-from-disk-test.js index 0e4aaf52..42d3198f 100644 --- a/test/unit/load-default-blueprint-from-disk-test.js +++ b/test/unit/load-default-blueprint-from-disk-test.js @@ -7,20 +7,20 @@ const sinon = require('sinon'); const utils = require('../../src/utils'); const loadDefaultBlueprintFromDisk = require('../../src/load-default-blueprint-from-disk'); -describe(loadDefaultBlueprintFromDisk, function() { +describe(loadDefaultBlueprintFromDisk, function () { let require; let getVersions; - beforeEach(function() { + beforeEach(function () { require = sinon.stub(utils, 'require'); getVersions = sinon.stub(utils, 'getVersions'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - it('handles missing package.json', async function() { + it('handles missing package.json', async function () { require = require.withArgs(path.normalize('/test/path/package')).throws(); let blueprint = await loadDefaultBlueprintFromDisk({ @@ -42,7 +42,7 @@ describe(loadDefaultBlueprintFromDisk, function() { }); }); - it('doesn\'t load version if supplied', async function() { + it("doesn't load version if supplied", async function () { require = require.withArgs(path.normalize('/test/path/package')).returns({ devDependencies: { 'ember-cli': '0.0.1' @@ -68,7 +68,7 @@ describe(loadDefaultBlueprintFromDisk, function() { }); }); - it('works', async function() { + it('works', async function () { require = require.withArgs(path.normalize('/test/path/package')).returns({ devDependencies: { 'ember-cli': '0.0.1' diff --git a/test/unit/normalize-blueprint-args-test.js b/test/unit/normalize-blueprint-args-test.js index d13ac061..b9b6cfde 100644 --- a/test/unit/normalize-blueprint-args-test.js +++ b/test/unit/normalize-blueprint-args-test.js @@ -4,8 +4,8 @@ const { describe, it } = require('../helpers/mocha'); const { expect } = require('../helpers/chai'); const normalizeBlueprintArgs = require('../../src/normalize-blueprint-args'); -describe(normalizeBlueprintArgs, function() { - it('copies if missing', function() { +describe(normalizeBlueprintArgs, function () { + it('copies if missing', function () { let blueprintArgs = normalizeBlueprintArgs({ blueprintName: 'foo' }); @@ -16,7 +16,7 @@ describe(normalizeBlueprintArgs, function() { }); }); - it('ignores if present', function() { + it('ignores if present', function () { let blueprintArgs = normalizeBlueprintArgs({ packageName: 'bar', blueprintName: 'foo' diff --git a/test/unit/save-blueprint-test.js b/test/unit/save-blueprint-test.js index d1e9d0be..984e6358 100644 --- a/test/unit/save-blueprint-test.js +++ b/test/unit/save-blueprint-test.js @@ -13,26 +13,32 @@ const loadSafeBlueprint = require('../../src/load-safe-blueprint'); const emberCliUpdateJsonPath = 'test-path'; -describe(_saveBlueprint, function() { +describe(_saveBlueprint, function () { let loadDefaultBlueprintFromDisk; let loadSafeBlueprintFile; let saveBlueprintFile; - beforeEach(function() { - loadDefaultBlueprintFromDisk = sinon.stub(utils, 'loadDefaultBlueprintFromDisk') - .withArgs({ cwd: emberCliUpdateJsonPath }).resolves(loadSafeBlueprint({ - packageName: defaultPackageName, - name: defaultAppBlueprintName, - version: '0.0.1' - })); - loadSafeBlueprintFile = sinon.stub(utils, 'loadSafeBlueprintFile') - .withArgs(emberCliUpdateJsonPath).resolves({ + beforeEach(function () { + loadDefaultBlueprintFromDisk = sinon + .stub(utils, 'loadDefaultBlueprintFromDisk') + .withArgs({ cwd: emberCliUpdateJsonPath }) + .resolves( + loadSafeBlueprint({ + packageName: defaultPackageName, + name: defaultAppBlueprintName, + version: '0.0.1' + }) + ); + loadSafeBlueprintFile = sinon + .stub(utils, 'loadSafeBlueprintFile') + .withArgs(emberCliUpdateJsonPath) + .resolves({ blueprints: [] }); saveBlueprintFile = sinon.stub(utils, 'saveBlueprintFile').resolves(); }); - afterEach(function() { + afterEach(function () { expect(loadDefaultBlueprintFromDisk).to.not.be.called; expect(loadSafeBlueprintFile).to.be.calledOnce; expect(saveBlueprintFile).to.be.calledOnce; @@ -48,37 +54,41 @@ describe(_saveBlueprint, function() { }); } - describe('default', function() { - it('saves default blueprint when missing', async function() { + describe('default', function () { + it('saves default blueprint when missing', async function () { await saveBlueprint(); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: defaultPackageName, - name: defaultAppBlueprintName, - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: defaultPackageName, + name: defaultAppBlueprintName, + version: '0.0.1' + }) + ] + }) + ); expect(loadDefaultBlueprintFromDisk).to.be.calledOnce; loadDefaultBlueprintFromDisk.resetHistory(); }); - it('saves default blueprint when missing version', async function() { + it('saves default blueprint when missing version', async function () { await saveBlueprint({}); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: defaultPackageName, - name: defaultAppBlueprintName, - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: defaultPackageName, + name: defaultAppBlueprintName, + version: '0.0.1' + }) + ] + }) + ); expect(loadDefaultBlueprintFromDisk).to.be.calledOnce; @@ -86,27 +96,29 @@ describe(_saveBlueprint, function() { }); }); - describe('custom', function() { - describe('create', function() { - it('saves blueprint', async function() { + describe('custom', function () { + describe('create', function () { + it('saves blueprint', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); - it('saves with location', async function() { + it('saves with location', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -114,19 +126,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - location: '/foo/bar', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + location: '/foo/bar', + version: '0.0.1' + }) + ] + }) + ); }); - it('saves with output repu', async function() { + it('saves with output repu', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -134,19 +148,21 @@ describe(_saveBlueprint, function() { outputRepo: 'output-repo-test' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - outputRepo: 'output-repo-test' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + outputRepo: 'output-repo-test' + }) + ] + }) + ); }); - it('saves with codemods url', async function() { + it('saves with codemods url', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -154,19 +170,21 @@ describe(_saveBlueprint, function() { codemodsSource: 'codemods-test' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - codemodsSource: 'codemods-test' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + codemodsSource: 'codemods-test' + }) + ] + }) + ); }); - it('saves with options', async function() { + it('saves with options', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -174,20 +192,22 @@ describe(_saveBlueprint, function() { options: ['test-option'] }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - options: ['test-option'] - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + options: ['test-option'] + }) + ] + }) + ); }); - describe('isBaseBlueprint', function() { - it('saves true', async function() { + describe('isBaseBlueprint', function () { + it('saves true', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -195,19 +215,21 @@ describe(_saveBlueprint, function() { isBaseBlueprint: true }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - isBaseBlueprint: true - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + isBaseBlueprint: true + }) + ] + }) + ); }); - it('saves false', async function() { + it('saves false', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', @@ -215,38 +237,42 @@ describe(_saveBlueprint, function() { isBaseBlueprint: false }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - isBaseBlueprint: false - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + isBaseBlueprint: false + }) + ] + }) + ); }); - it('ignores undefined', async function() { + it('ignores undefined', async function () { await saveBlueprint({ packageName: 'test-blueprint', name: 'test-blueprint', version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); }); - it('leaves other blueprints alone', async function() { + it('leaves other blueprints alone', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -263,23 +289,25 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint-2', - version: '0.0.0' - }), - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint-2', + version: '0.0.0' + }), + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); - it('leaves other packages alone', async function() { + it('leaves other packages alone', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -296,25 +324,27 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint-2', - name: 'test-blueprint', - version: '0.0.0' - }), - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint-2', + name: 'test-blueprint', + version: '0.0.0' + }), + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); }); - describe('update', function() { - it('saves blueprint', async function() { + describe('update', function () { + it('saves blueprint', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -331,18 +361,20 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); - it('saves with location', async function() { + it('saves with location', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -360,19 +392,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - location: '/foo/bar', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + location: '/foo/bar', + version: '0.0.1' + }) + ] + }) + ); }); - it('saves with output repo', async function() { + it('saves with output repo', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -390,19 +424,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - outputRepo: 'output-repo-test' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + outputRepo: 'output-repo-test' + }) + ] + }) + ); }); - it('saves with codemods url', async function() { + it('saves with codemods url', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -420,19 +456,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - codemodsSource: 'codemods-test' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + codemodsSource: 'codemods-test' + }) + ] + }) + ); }); - it('saves with options', async function() { + it('saves with options', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -450,20 +488,22 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - options: ['test-option'] - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + options: ['test-option'] + }) + ] + }) + ); }); - describe('isBaseBlueprint', function() { - it('saves true', async function() { + describe('isBaseBlueprint', function () { + it('saves true', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -481,19 +521,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - isBaseBlueprint: true - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + isBaseBlueprint: true + }) + ] + }) + ); }); - it('saves false', async function() { + it('saves false', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -511,19 +553,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1', - isBaseBlueprint: false - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1', + isBaseBlueprint: false + }) + ] + }) + ); }); - it('ignores undefined', async function() { + it('ignores undefined', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -540,19 +584,21 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }) + ] + }) + ); }); }); - it('leaves other blueprints alone', async function() { + it('leaves other blueprints alone', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -574,23 +620,25 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }), - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint-2', - version: '0.0.0' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }), + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint-2', + version: '0.0.0' + }) + ] + }) + ); }); - it('leaves other packages alone', async function() { + it('leaves other packages alone', async function () { loadSafeBlueprintFile.resolves({ blueprints: [ loadSafeBlueprint({ @@ -612,20 +660,22 @@ describe(_saveBlueprint, function() { version: '0.0.1' }); - expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal(JSON.stringify({ - blueprints: [ - loadSafeBlueprint({ - packageName: 'test-blueprint', - name: 'test-blueprint', - version: '0.0.1' - }), - loadSafeBlueprint({ - packageName: 'test-blueprint-2', - name: 'test-blueprint', - version: '0.0.0' - }) - ] - })); + expect(JSON.stringify(saveBlueprintFile.args[0][1])).to.equal( + JSON.stringify({ + blueprints: [ + loadSafeBlueprint({ + packageName: 'test-blueprint', + name: 'test-blueprint', + version: '0.0.1' + }), + loadSafeBlueprint({ + packageName: 'test-blueprint-2', + name: 'test-blueprint', + version: '0.0.0' + }) + ] + }) + ); }); }); });