diff --git a/.changeset/spotty-chairs-provide.md b/.changeset/spotty-chairs-provide.md new file mode 100644 index 00000000..9c832767 --- /dev/null +++ b/.changeset/spotty-chairs-provide.md @@ -0,0 +1,6 @@ +--- +"ember-codemod-remove-ember-css-modules": patch +"type-css-modules": patch +--- + +Refactored utilities diff --git a/.github/ISSUE_TEMPLATE/report-outdated-dependency.md b/.github/ISSUE_TEMPLATE/report-outdated-dependency.md index 389e3550..db76a9bd 100644 --- a/.github/ISSUE_TEMPLATE/report-outdated-dependency.md +++ b/.github/ISSUE_TEMPLATE/report-outdated-dependency.md @@ -14,12 +14,15 @@ Before you make a new issue, please search for similar issues. It's possible tha ## List outdated dependencies ๐Ÿ”— -When you ran `yarn outdated`, what did you see? - -| Package | Current version | Latest version | -|---|---|---| -| @babel/core | 7.17.0 | 7.18.9 | -| @babel/eslint-parser | 7.17.0 | 7.18.9 | +When you ran `pnpm outdated -r`, what did you see? + +```sh +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Package โ”‚ Current โ”‚ Latest โ”‚ Dependents โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ rollup (dev) โ”‚ 3.21.3 โ”‚ 3.22.0 โ”‚ embroider-css-modules โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` ## Risk analysis โš ๏ธ diff --git a/.gitignore b/.gitignore index 2497e070..404ebadb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ # compiled output -/dist/ -/tmp/ +dist/ +tmp/ # dependencies -/node_modules/ +node_modules/ # misc -/.DS_Store -/.env* -/.eslintcache +.DS_Store +.env* +.eslintcache +/.pnpm-debug.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c20a67c..60d4429c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,7 +108,14 @@ Here are some guidelines to help you and everyone else. GITHUB_TOKEN= pnpm publish:changelogs ``` -1. Create a tag such as `1.0.0` (the name satisfies the regular expression `^\d+\.\d+\.\d+`). +1. [Create a tag](https://github.com/ijlee2/embroider-css-modules/releases/new) such as `1.0.0` (the name satisfies the regular expression `^\d+\.\d+\.\d+`). + +1. Publish the package. + + ```sh + # From the workspace root + pnpm publish:packages + ``` @@ -170,7 +177,7 @@ Here are some suggestions to help you start: - Report bug - Report outdated dependency -1. When reporting a bug, please provide details to help me understand what's going on. If possible, please use the latest version of `embroider-css-modules` and set up a public demo that I and (other people) can check the code. +1. When reporting a bug, please provide details to help me understand what's going on. If possible, please use the latest version of `embroider-css-modules` and set up a public demo that I (and others) can check the code. diff --git a/packages/ember-codemod-remove-ember-css-modules/create-test-fixture.sh b/packages/ember-codemod-remove-ember-css-modules/create-test-fixture.sh index dfcaf4ac..1de83605 100755 --- a/packages/ember-codemod-remove-ember-css-modules/create-test-fixture.sh +++ b/packages/ember-codemod-remove-ember-css-modules/create-test-fixture.sh @@ -51,7 +51,7 @@ fi mkdir -p "tests/fixtures/$DESTINATION/input" mkdir -p "tests/fixtures/$DESTINATION/output" -echo "import { convertFixtureToJson } from '../../helpers/testing.js'; +echo "import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('$DESTINATION/input'); const outputProject = convertFixtureToJson('$DESTINATION/output'); diff --git a/packages/ember-codemod-remove-ember-css-modules/package.json b/packages/ember-codemod-remove-ember-css-modules/package.json index 930c42fc..ef61a1c7 100644 --- a/packages/ember-codemod-remove-ember-css-modules/package.json +++ b/packages/ember-codemod-remove-ember-css-modules/package.json @@ -33,15 +33,17 @@ }, "dependencies": { "@babel/parser": "^7.21.5", + "@codemod-utils/blueprints": "^0.1.1", + "@codemod-utils/files": "^0.1.0", + "@codemod-utils/json": "^0.1.1", "ember-template-recast": "^6.1.4", - "glob": "^10.2.2", - "lodash.template": "^4.5.0", "recast": "^0.23.1", "yargs": "^17.7.2" }, "devDependencies": { "@babel/core": "^7.21.5", "@babel/eslint-parser": "^7.21.3", + "@codemod-utils/tests": "^0.1.0", "@sondr3/minitest": "^0.1.1", "eslint": "^8.39.0", "eslint-config-prettier": "^8.8.0", @@ -49,7 +51,6 @@ "eslint-plugin-n": "^15.7.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-simple-import-sort": "^10.0.0", - "fixturify": "^3.0.0", "prettier": "^2.8.8" }, "engines": { diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/analyze-app.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/analyze-app.js index 5cb4e3ed..dc30702a 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/analyze-app.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/analyze-app.js @@ -1,6 +1,6 @@ import { join, parse } from 'node:path'; -import { findFiles, renameDirectory } from '../../../utils/files.js'; +import { findFiles, renameDirectory } from '@codemod-utils/files'; function findAndRenameFiles(findOptions, replaceOptions) { const { globPattern, ignoreList, projectRoot } = findOptions; diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/move-stylesheets.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/move-stylesheets.js index 29c08b04..f9adc78d 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/move-stylesheets.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/move-stylesheets.js @@ -3,7 +3,7 @@ import { findFiles, mapFilePaths, moveFiles, -} from '../../../utils/files.js'; +} from '@codemod-utils/files'; function moveRouteStylesheets(options) { const { projectRoot } = options; diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/import-styles.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/import-styles.js index 3074ac7d..45c1f834 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/import-styles.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/import-styles.js @@ -1,12 +1,11 @@ import { readFileSync } from 'node:fs'; import { join, parse } from 'node:path'; +import { processTemplate } from '@codemod-utils/blueprints'; +import { createFiles } from '@codemod-utils/files'; + import { ASTJavaScript as AST } from '../../../../utils/abstract-syntax-tree.js'; -import { - blueprintRoot, - processTemplate, -} from '../../../../utils/blueprints.js'; -import { createFiles } from '../../../../utils/files.js'; +import { blueprintsRoot } from '../../../../utils/blueprints.js'; import { parseEntityName } from '../../../../utils/string.js'; function removeTemplateOnlyComponentMethod(file, data) { @@ -134,7 +133,7 @@ function createClass(customizations, options) { const fileMapping = new Map( blueprintFilePaths.map((blueprintFilePath) => { const blueprintFile = readFileSync( - join(blueprintRoot, blueprintFilePath), + join(blueprintsRoot, blueprintFilePath), 'utf8', ); diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/update-templates.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/update-templates.js index 866138ce..5bd2c609 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/update-templates.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/shared/update-templates.js @@ -1,8 +1,9 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; +import { createFiles } from '@codemod-utils/files'; + import { ASTHandlebars as AST } from '../../../../utils/abstract-syntax-tree.js'; -import { createFiles } from '../../../../utils/files.js'; function sanitizeClassAndLocalClassAttributes(file) { function removeAttributeWithoutValue(attributeName, attributes) { diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-app-app-js.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-app-app-js.js index 15b0f9b5..4aea14b7 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-app-app-js.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-app-app-js.js @@ -1,8 +1,9 @@ import { readFileSync } from 'node:fs'; import { extname, join } from 'node:path'; +import { createFiles, findFiles } from '@codemod-utils/files'; + import { ASTJavaScript as AST } from '../../../utils/abstract-syntax-tree.js'; -import { createFiles, findFiles } from '../../../utils/files.js'; function addCssEntryPoint(file, data) { const traverse = AST.traverse(data.hasTypeScript); diff --git a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-package-json.js b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-package-json.js index c9f0675e..55f8a048 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-package-json.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/migration/ember-app/steps/update-package-json.js @@ -1,8 +1,9 @@ import { readFileSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; -import { decideVersion } from '../../../utils/blueprints.js'; -import { convertToMap, convertToObject } from '../../../utils/json.js'; +import { convertToMap, convertToObject } from '@codemod-utils/json'; + +import { getVersion } from '../../../utils/blueprints.js'; function updateDevDependencies(packageJson, options) { const { project } = options; @@ -22,7 +23,7 @@ function updateDevDependencies(packageJson, options) { } [...packagesToInstall].sort().forEach((packageName) => { - const version = decideVersion(packageName, options); + const version = getVersion(packageName, options); devDependencies.set(packageName, version); }); diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints.js index 922243ef..4b5711a7 100644 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints.js +++ b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints.js @@ -1,3 +1,2 @@ -export * from './blueprints/blueprint-root.js'; -export * from './blueprints/decide-version.js'; -export * from './blueprints/process-template.js'; +export * from './blueprints/blueprints-root.js'; +export * from './blueprints/get-version.js'; diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprint-root.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprint-root.js deleted file mode 100644 index d6ba83a2..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprint-root.js +++ /dev/null @@ -1,13 +0,0 @@ -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); - -function getBlueprintRoot() { - const srcDirectory = join(__dirname, '../..'); - - return join(srcDirectory, 'blueprints'); -} - -export const blueprintRoot = getBlueprintRoot(); diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprints-root.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprints-root.js new file mode 100644 index 00000000..f92430fe --- /dev/null +++ b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/blueprints-root.js @@ -0,0 +1,8 @@ +import { join } from 'node:path'; + +import { getFilePath } from '@codemod-utils/blueprints'; + +const fileURL = import.meta.url; +const srcDirectory = join(getFilePath(fileURL), '../..'); + +export const blueprintsRoot = join(srcDirectory, 'blueprints'); diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/decide-version.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/decide-version.js deleted file mode 100644 index 4195da98..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/decide-version.js +++ /dev/null @@ -1,25 +0,0 @@ -const latestVersions = new Map([ - ['embroider-css-modules', '0.1.1'], - ['type-css-modules', '0.1.1'], - ['webpack', '5.81.0'], -]); - -export function decideVersion(packageName, options) { - const { project } = options; - - const installedVersion = project.dependencies.get(packageName); - - if (installedVersion) { - return installedVersion; - } - - const latestVersion = latestVersions.get(packageName); - - if (!latestVersion) { - throw new RangeError( - `ERROR: The latest version of \`${packageName}\` is unknown.\n`, - ); - } - - return `^${latestVersion}`; -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/get-version.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/get-version.js new file mode 100644 index 00000000..e586a81d --- /dev/null +++ b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/get-version.js @@ -0,0 +1,16 @@ +import { decideVersion } from '@codemod-utils/blueprints'; + +const latestVersions = new Map([ + ['embroider-css-modules', '0.1.1'], + ['type-css-modules', '0.1.1'], + ['webpack', '5.81.0'], +]); + +export function getVersion(packageName, options) { + const { project } = options; + + return decideVersion(packageName, { + dependencies: project.dependencies, + latestVersions, + }); +} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/process-template.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/process-template.js deleted file mode 100644 index d383e384..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/blueprints/process-template.js +++ /dev/null @@ -1,12 +0,0 @@ -/* https://github.com/ember-cli/ember-cli/blob/v4.11.0/lib/utilities/process-template.js */ -import template from 'lodash.template'; - -export function processTemplate(file, data) { - const settings = { - escape: /<%-([\s\S]+?)%>/g, - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - }; - - return template(file, settings)(data); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files.js deleted file mode 100644 index 4bf69c71..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files.js +++ /dev/null @@ -1,7 +0,0 @@ -export * from './files/copy-files.js'; -export * from './files/create-files.js'; -export * from './files/find-files.js'; -export * from './files/map-file-paths.js'; -export * from './files/move-files.js'; -export * from './files/remove-directory-if-empty.js'; -export * from './files/remove-files.js'; diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/copy-files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/copy-files.js deleted file mode 100644 index 1bef3978..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/copy-files.js +++ /dev/null @@ -1,19 +0,0 @@ -import { copyFileSync, existsSync, mkdirSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -export function copyFiles(pathMapping, options) { - const { projectRoot } = options; - - pathMapping.forEach((newPath, oldPath) => { - const oldAbsolutePath = join(projectRoot, oldPath); - - const newAbsolutePath = join(projectRoot, newPath); - const newDirectory = dirname(newAbsolutePath); - - if (!existsSync(newDirectory)) { - mkdirSync(newDirectory, { recursive: true }); - } - - copyFileSync(oldAbsolutePath, newAbsolutePath); - }); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/create-files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/create-files.js deleted file mode 100644 index fb9b1c4e..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/create-files.js +++ /dev/null @@ -1,17 +0,0 @@ -import { existsSync, mkdirSync, writeFileSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -export function createFiles(fileMapping, options) { - const { projectRoot } = options; - - fileMapping.forEach((file, newPath) => { - const newAbsolutePath = join(projectRoot, newPath); - const newDirectory = dirname(newAbsolutePath); - - if (!existsSync(newDirectory)) { - mkdirSync(newDirectory, { recursive: true }); - } - - writeFileSync(newAbsolutePath, file, 'utf8'); - }); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/find-files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/find-files.js deleted file mode 100644 index d2384bba..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/find-files.js +++ /dev/null @@ -1,28 +0,0 @@ -import { globSync } from 'glob'; - -export function findFiles(pattern, { cwd, ignoreList = [] }) { - if (!pattern) { - throw new RangeError('ERROR: The glob pattern is unknown.\n'); - } - - if (!cwd) { - throw new RangeError('ERROR: The current working directory is unknown.\n'); - } - - const filePaths = globSync(pattern, { - cwd, - dot: true, - ignore: ignoreList, - nodir: true, - }); - - return filePaths; -} - -export function unionize(files) { - if (files.length <= 1) { - return files.join(','); - } - - return `{${files.join(',')}}`; -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/map-file-paths.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/map-file-paths.js deleted file mode 100644 index 497e85b4..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/map-file-paths.js +++ /dev/null @@ -1,25 +0,0 @@ -import { join } from 'node:path'; - -export function renameDirectory(oldPath, { from, to }) { - if (from === '') { - return join(to, oldPath); - } - - if (!oldPath.startsWith(`${from}/`)) { - return oldPath; - } - - return join(to, oldPath.replace(`${from}/`, '')); -} - -export function mapFilePaths(filePaths, directory) { - const { from, to } = directory; - - return new Map( - filePaths.map((filePath) => { - const newPath = renameDirectory(filePath, { from, to }); - - return [filePath, newPath]; - }), - ); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/move-files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/move-files.js deleted file mode 100644 index f6a37af4..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/move-files.js +++ /dev/null @@ -1,22 +0,0 @@ -import { existsSync, mkdirSync, renameSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js'; - -export function moveFiles(pathMapping, options) { - const { projectRoot } = options; - - pathMapping.forEach((newPath, oldPath) => { - const oldAbsolutePath = join(projectRoot, oldPath); - - const newAbsolutePath = join(projectRoot, newPath); - const newDirectory = dirname(newAbsolutePath); - - if (!existsSync(newDirectory)) { - mkdirSync(newDirectory, { recursive: true }); - } - - renameSync(oldAbsolutePath, newAbsolutePath); - removeDirectoryIfEmpty({ oldPath, projectRoot }); - }); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-directory-if-empty.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-directory-if-empty.js deleted file mode 100644 index cac449f4..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-directory-if-empty.js +++ /dev/null @@ -1,19 +0,0 @@ -import { readdirSync, rmSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -export function removeDirectoryIfEmpty({ oldPath, projectRoot }) { - const directories = dirname(oldPath).split('/'); - const depth = directories.length; - - for (let i = 0; i < depth; i++) { - const directory = join(projectRoot, ...directories); - const numFilesLeft = readdirSync(directory).length; - - if (numFilesLeft > 0) { - continue; - } - - rmSync(directory, { recursive: true }); - directories.pop(); - } -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-files.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-files.js deleted file mode 100644 index 7838fc2f..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/files/remove-files.js +++ /dev/null @@ -1,15 +0,0 @@ -import { rmSync } from 'node:fs'; -import { join } from 'node:path'; - -import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js'; - -export function removeFiles(oldPaths, options) { - const { projectRoot } = options; - - oldPaths.forEach((oldPath) => { - const oldAbsolutePath = join(projectRoot, oldPath); - - rmSync(oldAbsolutePath); - removeDirectoryIfEmpty({ oldPath, projectRoot }); - }); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/json.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/json.js deleted file mode 100644 index 50c65fc8..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/json.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from './json/convert-to-map.js'; -export * from './json/convert-to-object.js'; diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-map.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-map.js deleted file mode 100644 index 28c1d017..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-map.js +++ /dev/null @@ -1,3 +0,0 @@ -export function convertToMap(object = {}) { - return new Map(Object.entries(object)); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-object.js b/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-object.js deleted file mode 100644 index cef1a5b8..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/src/utils/json/convert-to-object.js +++ /dev/null @@ -1,5 +0,0 @@ -export function convertToObject(map) { - const sortedMap = new Map([...map.entries()].sort()); - - return Object.fromEntries(sortedMap); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-glint/index.js b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-glint/index.js index d2a093ea..7bf3afde 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-glint/index.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-glint/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-container-query-glint/input'); const outputProject = convertFixtureToJson('ember-container-query-glint/output'); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-javascript/index.js b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-javascript/index.js index 70624e12..000be771 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-javascript/index.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-javascript/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-container-query-javascript/input'); const outputProject = convertFixtureToJson('ember-container-query-javascript/output'); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-nested/index.js b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-nested/index.js index b6265a8d..48af871f 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-nested/index.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-nested/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-container-query-nested/input'); const outputProject = convertFixtureToJson('ember-container-query-nested/output'); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-typescript/index.js b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-typescript/index.js index 83eb8e67..bdbfaf3b 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-typescript/index.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/fixtures/ember-container-query-typescript/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-container-query-typescript/input'); const outputProject = convertFixtureToJson('ember-container-query-typescript/output'); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing.js b/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing.js deleted file mode 100644 index b921c7a8..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing.js +++ /dev/null @@ -1,9 +0,0 @@ -import { strict as assert } from 'node:assert'; - -import { test } from '@sondr3/minitest'; - -export { assert, test }; - -export * from './testing/assert-fixture.js'; -export * from './testing/convert-fixture-to-json.js'; -export * from './testing/load-fixture.js'; diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/assert-fixture.js b/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/assert-fixture.js deleted file mode 100644 index ac6ca282..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/assert-fixture.js +++ /dev/null @@ -1,9 +0,0 @@ -import { strict as assert } from 'node:assert'; - -import fixturify from 'fixturify'; - -export function assertFixture(outputProject, codemodOptions) { - const { projectRoot } = codemodOptions; - - assert.deepStrictEqual(fixturify.readSync(projectRoot), outputProject); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/convert-fixture-to-json.js b/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/convert-fixture-to-json.js deleted file mode 100644 index cead0660..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/convert-fixture-to-json.js +++ /dev/null @@ -1,48 +0,0 @@ -import { readFileSync } from 'node:fs'; -import { join } from 'node:path'; - -import { globSync } from 'glob'; - -function updateJson(json, { currentDirectory, keys }) { - const key = keys.shift(); - const isFile = keys.length === 0; - - if (isFile) { - json[key] = readFileSync(join(currentDirectory, key), 'utf8'); - - return; - } - - if (!(key in json)) { - json[key] = {}; - } - - updateJson(json[key], { - currentDirectory: join(currentDirectory, key), - keys, - }); -} - -function createJson(filePaths = [], currentDirectory) { - const json = {}; - - filePaths.forEach((filePath) => { - const keys = filePath.split('/'); - - updateJson(json, { currentDirectory, keys }); - }); - - return json; -} - -export function convertFixtureToJson(projectRoot) { - const currentDirectory = `${process.cwd()}/tests/fixtures/${projectRoot}`; - - const filePaths = globSync('**/*', { - cwd: currentDirectory, - dot: true, - nodir: true, - }); - - return createJson(filePaths, currentDirectory); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/load-fixture.js b/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/load-fixture.js deleted file mode 100644 index 471fd425..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/helpers/testing/load-fixture.js +++ /dev/null @@ -1,13 +0,0 @@ -import { existsSync, rmSync } from 'node:fs'; - -import fixturify from 'fixturify'; - -export function loadFixture(inputProject, codemodOptions) { - const { projectRoot } = codemodOptions; - - if (existsSync(projectRoot)) { - rmSync(projectRoot, { recursive: true }); - } - - fixturify.writeSync(projectRoot, inputProject); -} diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/glint.test.js index 2accc2c5..2b7d116c 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/glint.test.js @@ -1,14 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { migrateEmberApp } from '../../../../../src/migration/ember-app/index.js'; import { inputProject, outputProject, } from '../../../../fixtures/ember-container-query-glint/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | index | ember-container-query > glint', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/javascript.test.js index 7f701318..3b7ea8c6 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/javascript.test.js @@ -1,14 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { migrateEmberApp } from '../../../../../src/migration/ember-app/index.js'; import { inputProject, outputProject, } from '../../../../fixtures/ember-container-query-javascript/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | index | ember-container-query > javascript', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/nested.test.js index 39e38b1c..0495d9c9 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/nested.test.js @@ -1,14 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { migrateEmberApp } from '../../../../../src/migration/ember-app/index.js'; import { inputProject, outputProject, } from '../../../../fixtures/ember-container-query-nested/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/nested.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | index | ember-container-query > nested', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/typescript.test.js index db870380..9b898d09 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/index/ember-container-query/typescript.test.js @@ -1,14 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { migrateEmberApp } from '../../../../../src/migration/ember-app/index.js'; import { inputProject, outputProject, } from '../../../../fixtures/ember-container-query-typescript/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/typescript.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | index | ember-container-query > typescript', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/glint.test.js index 811e2dfb..fedd763e 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/glint.test.js @@ -1,3 +1,5 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { analyzeApp } from '../../../../../src/migration/ember-app/steps/index.js'; import { inputProject } from '../../../../fixtures/ember-container-query-glint/index.js'; import { @@ -5,7 +7,6 @@ import { context, options, } from '../../../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | analyze-app > glint', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/javascript.test.js index b5fac021..b4964925 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/javascript.test.js @@ -1,3 +1,5 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { analyzeApp } from '../../../../../src/migration/ember-app/steps/index.js'; import { inputProject } from '../../../../fixtures/ember-container-query-javascript/index.js'; import { @@ -5,7 +7,6 @@ import { context, options, } from '../../../../helpers/shared-test-setups/javascript.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | analyze-app > javascript', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/nested.test.js index e1d5e82b..bd185efc 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/nested.test.js @@ -1,3 +1,5 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { analyzeApp } from '../../../../../src/migration/ember-app/steps/index.js'; import { inputProject } from '../../../../fixtures/ember-container-query-nested/index.js'; import { @@ -5,7 +7,6 @@ import { context, options, } from '../../../../helpers/shared-test-setups/nested.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | analyze-app > nested', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/typescript.test.js index b7f6b1a0..142d8afa 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/analyze-app/typescript.test.js @@ -1,3 +1,5 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { analyzeApp } from '../../../../../src/migration/ember-app/steps/index.js'; import { inputProject } from '../../../../fixtures/ember-container-query-typescript/index.js'; import { @@ -5,7 +7,6 @@ import { context, options, } from '../../../../helpers/shared-test-setups/typescript.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | analyze-app > typescript', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-an-empty-file.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-an-empty-file.test.js index f7895936..2d8d5720 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-an-empty-file.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-an-empty-file.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > error handling (package.json is an empty file)', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-not-a-valid-json.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-not-a-valid-json.test.js index 8e70a085..17a9b64f 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-not-a-valid-json.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/error-handling-package-json-is-not-a-valid-json.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > error handling (package.json is not a valid JSON)', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/glint.test.js index 7a5f6e4d..a9d262cd 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/glint.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > glint', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/idempotency.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/idempotency.test.js index 9fc63cb0..113b6dcd 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/idempotency.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/idempotency.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > idempotency', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/javascript.test.js index 0308dc43..689cdd36 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/javascript.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/javascript.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > javascript', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/nested.test.js index ef6a1e02..29e8276b 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/nested.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/nested.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > nested', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/typescript.test.js index 6ac0afe4..721c7e70 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/create-options/typescript.test.js @@ -1,6 +1,7 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions } from '../../../../helpers/shared-test-setups/typescript.js'; -import { assert, loadFixture, test } from '../../../../helpers/testing.js'; test('migration | ember-app | steps | create-options > typescript', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/glint.test.js index a467bf51..36e85172 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/glint.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInComponents } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/glint.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-components > glint', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/javascript.test.js index c159450e..cd575f5f 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/javascript.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInComponents } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/javascript.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-components > javascript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/nested.test.js index 29ce6a15..60dd2485 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/nested.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInComponents } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/nested.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-components > nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/typescript.test.js index c8609e34..09fc479a 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-components/typescript.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInComponents } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/typescript.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-components > typescript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/glint.test.js index 72651801..1a367398 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/glint.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInRoutes } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/glint.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-routes > glint', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/javascript.test.js index 646766d8..f5bd6b31 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/javascript.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInRoutes } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/javascript.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-routes > javascript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/nested.test.js index 96dc426f..9cbb51d6 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/nested.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInRoutes } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/nested.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-routes > nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/typescript.test.js index 5626039a..75abe610 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/import-styles-in-routes/typescript.test.js @@ -1,15 +1,16 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + import { importStylesInRoutes } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, context, options, } from '../../../../helpers/shared-test-setups/typescript.js'; -import { - assertFixture, - convertFixtureToJson, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | import-styles-in-routes > typescript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/glint.test.js index e1e46cf4..63a5cef2 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/glint.test.js @@ -1,13 +1,10 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { moveStylesheets } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, options, } from '../../../../helpers/shared-test-setups/glint.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | move-stylesheets > glint', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/javascript.test.js index 1335e4e2..ab325f19 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/javascript.test.js @@ -1,13 +1,10 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { moveStylesheets } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, options, } from '../../../../helpers/shared-test-setups/javascript.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | move-stylesheets > javascript', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/nested.test.js index 99bbbdf9..56a47c20 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/nested.test.js @@ -1,13 +1,10 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { moveStylesheets } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, options, } from '../../../../helpers/shared-test-setups/nested.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | move-stylesheets > nested', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/typescript.test.js index ab5f4e00..6407dfa0 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/move-stylesheets/typescript.test.js @@ -1,13 +1,10 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { moveStylesheets } from '../../../../../src/migration/ember-app/steps/index.js'; import { codemodOptions, options, } from '../../../../helpers/shared-test-setups/typescript.js'; -import { - assertFixture, - loadFixture, - test, -} from '../../../../helpers/testing.js'; test('migration | ember-app | steps | move-stylesheets > typescript', function () { const inputProject = { diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/glint.test.js index a7a04719..687861fe 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/glint.test.js @@ -1,14 +1,15 @@ -import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/glint.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/glint.js'; test('migration | ember-app | steps | update-app-app-js > glint', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/javascript.test.js index 1bfa685c..2b32af01 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/javascript.test.js @@ -1,14 +1,15 @@ -import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/javascript.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/javascript.js'; test('migration | ember-app | steps | update-app-app-js > javascript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/nested.test.js index 35308bc6..85d4a13c 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/nested.test.js @@ -1,14 +1,15 @@ -import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/nested.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/nested.js'; test('migration | ember-app | steps | update-app-app-js > nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/typescript.test.js index 7025a2a9..7e536261 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-app-app-js/typescript.test.js @@ -1,14 +1,15 @@ -import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/typescript.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateAppAppJs } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/typescript.js'; test('migration | ember-app | steps | update-app-app-js > typescript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/glint.test.js index 277d3b5a..fede360f 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/glint.test.js @@ -1,18 +1,19 @@ /* Place the test components directly under `app/components`. */ -import { updateComponentTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/glint.js'; import { assert, assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateComponentTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/glint.js'; function getContext(fileName) { const entityName = fileName.replace(new RegExp(/\.hbs$/), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/nested.test.js index cd938f77..330970dc 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-component-templates/nested.test.js @@ -3,18 +3,19 @@ component templates. For the nested component structure, it is sufficient to check that the template files can be read. */ -import { updateComponentTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/nested.js'; import { assert, assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateComponentTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/nested.js'; function getContext(folderName) { const entityName = folderName.replace(new RegExp(/\.hbs$/), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/glint.test.js index f9f2305c..d4a2e03a 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/glint.test.js @@ -1,14 +1,15 @@ -import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/glint.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/glint.js'; test('migration | ember-app | steps | update-package-json > glint', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/javascript.test.js index 770d4439..ffa460eb 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/javascript.test.js @@ -1,14 +1,15 @@ -import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/javascript.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/javascript.js'; test('migration | ember-app | steps | update-package-json > javascript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/nested.test.js index 4e386bf8..c591849c 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/nested.test.js @@ -1,14 +1,15 @@ -import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/nested.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/nested.js'; test('migration | ember-app | steps | update-package-json > nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/typescript.test.js index ed6c383a..9eade4c0 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-package-json/typescript.test.js @@ -1,14 +1,15 @@ -import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/typescript.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updatePackageJson } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/typescript.js'; test('migration | ember-app | steps | update-package-json > typescript', function () { const inputProject = convertFixtureToJson( diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/glint.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/glint.test.js index c4b45803..af63749d 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/glint.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/glint.test.js @@ -2,18 +2,19 @@ At the moment, we update component and route templates in the same way. Please check the input and output for `update-component-templates`. */ -import { updateRouteTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/glint.js'; import { assert, assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateRouteTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/glint.js'; function getContext(fileName) { const entityName = fileName.replace(new RegExp(/\.hbs$/), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/nested.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/nested.test.js index 629bf24b..6c17aa2a 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/nested.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/migration/ember-app/steps/update-route-templates/nested.test.js @@ -2,18 +2,19 @@ At the moment, we update component and route templates in the same way. Please check the input and output for `update-component-templates`. */ -import { updateRouteTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; -import { - codemodOptions, - options, -} from '../../../../helpers/shared-test-setups/nested.js'; import { assert, assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { updateRouteTemplates } from '../../../../../src/migration/ember-app/steps/index.js'; +import { + codemodOptions, + options, +} from '../../../../helpers/shared-test-setups/nested.js'; function getContext(fileName) { const entityName = fileName.replace(new RegExp(/\.hbs$/), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/handlebars.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/handlebars.test.js index a7ee932a..da6749aa 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/handlebars.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/handlebars.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { ASTHandlebars as AST } from '../../../src/utils/abstract-syntax-tree.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | abstract-syntax-tree | handlebars > file is empty', function () { const oldFile = ''; diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/javascript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/javascript.test.js index 5191c2c1..2aa8c622 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/javascript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/javascript.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { ASTJavaScript as AST } from '../../../src/utils/abstract-syntax-tree.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | abstract-syntax-tree | javascript > file is empty', function () { const oldFile = ''; diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/typescript.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/typescript.test.js index 6bc4b2a0..7fcdc335 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/typescript.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/abstract-syntax-tree/typescript.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { ASTJavaScript as AST } from '../../../src/utils/abstract-syntax-tree.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | abstract-syntax-tree | typescript > file is empty', function () { const oldFile = ''; diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprint-root.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprint-root.test.js deleted file mode 100644 index f3c31aa6..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprint-root.test.js +++ /dev/null @@ -1,6 +0,0 @@ -import { blueprintRoot } from '../../../src/utils/blueprints.js'; -import { assert, test } from '../../helpers/testing.js'; - -test('utils | blueprints | blueprint-root', function () { - assert.strictEqual(blueprintRoot.endsWith('src/blueprints'), true); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprints-root.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprints-root.test.js new file mode 100644 index 00000000..df5ed4f0 --- /dev/null +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/blueprints-root.test.js @@ -0,0 +1,7 @@ +import { assert, test } from '@codemod-utils/tests'; + +import { blueprintsRoot } from '../../../src/utils/blueprints.js'; + +test('utils | blueprints | blueprints-root', function () { + assert.strictEqual(blueprintsRoot.endsWith('src/blueprints'), true); +}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/decide-version.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/decide-version.test.js deleted file mode 100644 index 16c8ed7e..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/decide-version.test.js +++ /dev/null @@ -1,31 +0,0 @@ -import { decideVersion } from '../../../src/utils/blueprints.js'; -import { options } from '../../helpers/shared-test-setups/glint.js'; -import { assert, test } from '../../helpers/testing.js'; - -test('utils | blueprints | decide-version > package is already installed', function () { - const version = decideVersion('webpack', options); - - assert.strictEqual(version, '^5.77.0'); -}); - -test('utils | blueprints | decide-version > package is not installed and we provide the latest version', function () { - const version = decideVersion('embroider-css-modules', options); - - assert.strictEqual(version, '^0.1.1'); -}); - -test('utils | blueprints | decide-version > package is not installed and we forgot to provide the latest version', function () { - assert.throws( - () => { - decideVersion('some-package-not-part-of-blueprint', options); - }, - (error) => { - assert.strictEqual( - error.message, - 'ERROR: The latest version of `some-package-not-part-of-blueprint` is unknown.\n', - ); - - return true; - }, - ); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/get-version.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/get-version.test.js new file mode 100644 index 00000000..e2e32d82 --- /dev/null +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/get-version.test.js @@ -0,0 +1,10 @@ +import { assert, test } from '@codemod-utils/tests'; + +import { getVersion } from '../../../src/utils/blueprints.js'; +import { options } from '../../helpers/shared-test-setups/glint.js'; + +test('utils | blueprints | get-version', function () { + const version = getVersion('webpack', options); + + assert.strictEqual(version, '^5.77.0'); +}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/escape.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/escape.test.js deleted file mode 100644 index 622f458b..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/escape.test.js +++ /dev/null @@ -1,16 +0,0 @@ -import { processTemplate } from '../../../../src/utils/blueprints.js'; -import { assert, test } from '../../../helpers/testing.js'; - -test('utils | blueprints | process-template > escape', function () { - const blueprintFile = '<%- context.htmlCode %>'; - - const file = processTemplate(blueprintFile, { - context: { - htmlCode: 'I ๐Ÿงก container queries!', - }, - }); - - const expectedValue = '<em>I ๐Ÿงก container queries!</em>'; - - assert.strictEqual(file, expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/evaluate.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/evaluate.test.js deleted file mode 100644 index f6cfebea..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/evaluate.test.js +++ /dev/null @@ -1,31 +0,0 @@ -import { processTemplate } from '../../../../src/utils/blueprints.js'; -import { assert, test } from '../../../helpers/testing.js'; - -test('utils | blueprints | process-template > evaluate', function () { - const blueprintFile = [ - `import Component from '@glimmer/component';`, - ``, - `<% if (options.packages.app.hasTypeScript) { %>export default class NavigationMenuComponent extends Component {}`, - `<% } else { %>export default class NavigationMenuComponent extends Component {}`, - `<% } %>`, - ].join('\n'); - - const file = processTemplate(blueprintFile, { - options: { - packages: { - app: { - hasTypeScript: true, - }, - }, - }, - }); - - const expectedValue = [ - `import Component from '@glimmer/component';`, - ``, - `export default class NavigationMenuComponent extends Component {}`, - ``, - ].join('\n'); - - assert.strictEqual(file, expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/interpolate.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/interpolate.test.js deleted file mode 100644 index 22a59458..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/blueprints/process-template/interpolate.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import { processTemplate } from '../../../../src/utils/blueprints.js'; -import { assert, test } from '../../../helpers/testing.js'; - -test('utils | blueprints | process-template > interpolate', function () { - const blueprintFile = [ - `export default class <%= componentName %>Component extends Component<<%= componentName %>Signature> {}`, - ].join('\n'); - - const file = processTemplate(blueprintFile, { - componentName: 'NavigationMenu', - }); - - const expectedValue = [ - `export default class NavigationMenuComponent extends Component {}`, - ].join('\n'); - - assert.strictEqual(file, expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/copy-files.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/copy-files.test.js deleted file mode 100644 index 40e8e9f5..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/copy-files.test.js +++ /dev/null @@ -1,69 +0,0 @@ -import { copyFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | copy-files', function () { - const inputProject = { - app: { - components: { - ui: { - form: { - 'information.css': '', - 'information.d.ts': 'some code for information.d.ts', - 'information.hbs': '', - }, - }, - widgets: { - 'widget-1.css': '', - 'widget-1.hbs': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.d.ts': 'some code for navigation-menu.d.ts', - 'navigation-menu.hbs': '', - }, - }, - }; - - const outputProject = { - app: { - components: { - ui: { - form: { - 'information.css': '', - 'information.d.ts': 'some code for information.d.ts', - 'information.hbs': '', - 'information.ts': 'some code for information.d.ts', - }, - }, - widgets: { - 'widget-1.css': '', - 'widget-1.hbs': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.d.ts': 'some code for navigation-menu.d.ts', - 'navigation-menu.hbs': '', - 'navigation-menu.ts': 'some code for navigation-menu.d.ts', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const migrationStrategy = new Map([ - [ - 'app/components/navigation-menu.d.ts', - 'app/components/navigation-menu.ts', - ], - [ - 'app/components/ui/form/information.d.ts', - 'app/components/ui/form/information.ts', - ], - ]); - - copyFiles(migrationStrategy, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/create-files.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/create-files.test.js deleted file mode 100644 index 65e86d3b..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/create-files.test.js +++ /dev/null @@ -1,44 +0,0 @@ -import { createFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | create-files', function () { - const inputProject = {}; - - const outputProject = { - app: { - components: { - ui: { - form: { - 'information.ts': 'some code for information.ts', - }, - }, - widgets: { - 'widget-1.ts': 'some code for widget-1.ts', - }, - 'navigation-menu.ts': 'some code for navigation-menu.ts', - }, - controllers: { - 'application.ts': 'some code for application.ts', - 'index.ts': 'some code for index.ts', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const fileMapping = new Map([ - ['app/components/navigation-menu.ts', 'some code for navigation-menu.ts'], - ['app/components/ui/form/information.ts', 'some code for information.ts'], - ['app/components/widgets/widget-1.ts', 'some code for widget-1.ts'], - ['app/controllers/application.ts', 'some code for application.ts'], - ['app/controllers/index.ts', 'some code for index.ts'], - ]); - - createFiles(fileMapping, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/find-files.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/find-files.test.js deleted file mode 100644 index 853d70f7..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/find-files.test.js +++ /dev/null @@ -1,65 +0,0 @@ -import { findFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assert, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | find-files', function () { - const inputProject = { - app: { - components: { - ui: { - 'page.css': '', - 'page.css.d.ts': '', - 'page.hbs': '', - 'page.ts': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.css.d.ts': '', - 'navigation-menu.hbs': '', - 'navigation-menu.ts': '', - }, - controllers: { - 'application.css': '', - 'application.css.d.ts': '', - }, - styles: { - 'app.css': '', - 'app.css.d.ts': '', - }, - }, - node_modules: { - 'ember-container-query': { - dist: { - components: { - 'container-query.css': '', - }, - }, - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - let filePaths = findFiles('app/components/**/*.css', { - cwd: options.projectRoot, - }); - - assert.deepStrictEqual(filePaths.sort(), [ - 'app/components/navigation-menu.css', - 'app/components/ui/page.css', - ]); - - filePaths = findFiles('**/*.css', { - cwd: options.projectRoot, - ignoreList: ['node_modules/**/*'], - }); - - assert.deepStrictEqual(filePaths.sort(), [ - 'app/components/navigation-menu.css', - 'app/components/ui/page.css', - 'app/controllers/application.css', - 'app/styles/app.css', - ]); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/map-file-paths.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/map-file-paths.test.js deleted file mode 100644 index 97dc2d44..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/map-file-paths.test.js +++ /dev/null @@ -1,98 +0,0 @@ -import { mapFilePaths } from '../../../src/utils/files.js'; -import { assert, test } from '../../helpers/testing.js'; - -test('utils | files | map-file-paths > base case', function () { - const filePaths = [ - 'app/styles/application.css', - 'app/styles/index.css', - 'app/styles/products.css', - 'app/styles/products/product.css', - ]; - - const pathMapping = mapFilePaths(filePaths, { - from: 'app/styles', - to: 'app/controllers', - }); - - const expectedValue = new Map([ - ['app/styles/application.css', 'app/controllers/application.css'], - ['app/styles/index.css', 'app/controllers/index.css'], - ['app/styles/products.css', 'app/controllers/products.css'], - ['app/styles/products/product.css', 'app/controllers/products/product.css'], - ]); - - assert.deepStrictEqual(pathMapping, expectedValue); -}); - -test('utils | files | map-file-paths > file paths are mapped from the project root', function () { - const filePaths = [ - 'app/styles/application.css', - 'app/styles/index.css', - 'app/styles/products.css', - 'app/styles/products/product.css', - ]; - - const pathMapping = mapFilePaths(filePaths, { - from: '', - to: 'css-modules', - }); - - const expectedValue = new Map([ - ['app/styles/application.css', 'css-modules/app/styles/application.css'], - ['app/styles/index.css', 'css-modules/app/styles/index.css'], - ['app/styles/products.css', 'css-modules/app/styles/products.css'], - [ - 'app/styles/products/product.css', - 'css-modules/app/styles/products/product.css', - ], - ]); - - assert.deepStrictEqual(pathMapping, expectedValue); -}); - -test('utils | files | map-file-paths > file paths are mapped to the project root', function () { - const filePaths = [ - 'app/styles/application.css', - 'app/styles/index.css', - 'app/styles/products.css', - 'app/styles/products/product.css', - ]; - - const pathMapping = mapFilePaths(filePaths, { - from: 'app/styles', - to: '', - }); - - const expectedValue = new Map([ - ['app/styles/application.css', 'application.css'], - ['app/styles/index.css', 'index.css'], - ['app/styles/products.css', 'products.css'], - ['app/styles/products/product.css', 'products/product.css'], - ]); - - assert.deepStrictEqual(pathMapping, expectedValue); -}); - -test('utils | files | map-file-paths > file paths remain when there is no match', function () { - const filePaths = [ - 'app/components/navigation-menu.css', - 'app/styles', - 'app/styles.css', - ]; - - const pathMapping = mapFilePaths(filePaths, { - from: 'app/styles', - to: 'app/controllers', - }); - - const expectedValue = new Map([ - [ - 'app/components/navigation-menu.css', - 'app/components/navigation-menu.css', - ], - ['app/styles', 'app/styles'], - ['app/styles.css', 'app/styles.css'], - ]); - - assert.deepStrictEqual(pathMapping, expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/move-files.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/move-files.test.js deleted file mode 100644 index 5b19dc9a..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/move-files.test.js +++ /dev/null @@ -1,47 +0,0 @@ -import { moveFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | move-files', function () { - const inputProject = { - app: { - styles: { - products: { - 'product.css': 'some code for product.css', - }, - 'application.css': 'some code for application.css', - 'index.css': 'some code for index.css', - 'products.css': 'some code for products.css', - }, - }, - }; - - const outputProject = { - app: { - controllers: { - products: { - 'product.css': 'some code for product.css', - }, - 'application.css': 'some code for application.css', - 'index.css': 'some code for index.css', - 'products.css': 'some code for products.css', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const migrationStrategy = new Map([ - ['app/styles/application.css', 'app/controllers/application.css'], - ['app/styles/index.css', 'app/controllers/index.css'], - ['app/styles/products.css', 'app/controllers/products.css'], - ['app/styles/products/product.css', 'app/controllers/products/product.css'], - ]); - - moveFiles(migrationStrategy, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-directory-if-empty.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-directory-if-empty.test.js deleted file mode 100644 index a9496396..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-directory-if-empty.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { removeDirectoryIfEmpty } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | remove-directory-if-empty > parent directories are empty', function () { - const inputProject = { - app: { - components: {}, - }, - }; - - const outputProject = {}; - - loadFixture(inputProject, codemodOptions); - - removeDirectoryIfEmpty({ - oldPath: 'app/components/navigation-menu.css.d.ts', - projectRoot: options.projectRoot, - }); - - assertFixture(outputProject, codemodOptions); -}); - -test('utils | files | remove-directory-if-empty > a parent directory is not empty', function () { - const inputProject = { - app: { - components: {}, - '.gitkeep': '', - }, - }; - - const outputProject = { - app: { - '.gitkeep': '', - }, - }; - - loadFixture(inputProject, codemodOptions); - - removeDirectoryIfEmpty({ - oldPath: 'app/components/navigation-menu.css.d.ts', - projectRoot: options.projectRoot, - }); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-files.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-files.test.js deleted file mode 100644 index 59940c9a..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/files/remove-files.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import { removeFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/glint.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | remove-files', function () { - const inputProject = { - app: { - components: { - ui: { - form: { - 'information.css': '', - 'information.d.ts': '', - 'information.hbs': '', - }, - }, - widgets: { - 'widget-1.css': '', - 'widget-1.hbs': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.d.ts': '', - 'navigation-menu.hbs': '', - }, - }, - }; - - const outputProject = { - app: { - components: { - ui: { - form: { - 'information.css': '', - 'information.d.ts': '', - }, - }, - widgets: { - 'widget-1.css': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.d.ts': '', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const filePaths = [ - 'app/components/navigation-menu.hbs', - 'app/components/ui/form/information.hbs', - 'app/components/widgets/widget-1.hbs', - ]; - - removeFiles(filePaths, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-map.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-map.test.js deleted file mode 100644 index 478b8ab7..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-map.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { convertToMap } from '../../../src/utils/json.js'; -import { assert, test } from '../../helpers/testing.js'; - -test('utils | json | convert-to-map', function () { - const devDependencies = { - '@embroider/compat': '^2.1.1', - '@embroider/core': '^2.1.1', - '@glint/core': '^v1.0.0-beta.4', - '@glint/environment-ember-loose': '^v1.0.0-beta.4', - '@glint/template': '^v1.0.0-beta.4', - 'ember-css-modules': '^2.0.1', - typescript: '^5.0.3', - }; - - const expectedValue = new Map([ - ['@embroider/compat', '^2.1.1'], - ['@embroider/core', '^2.1.1'], - ['@glint/core', '^v1.0.0-beta.4'], - ['@glint/environment-ember-loose', '^v1.0.0-beta.4'], - ['@glint/template', '^v1.0.0-beta.4'], - ['ember-css-modules', '^2.0.1'], - ['typescript', '^5.0.3'], - ]); - - assert.deepEqual(convertToMap(devDependencies), expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-object.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-object.test.js deleted file mode 100644 index 7ac28ba2..00000000 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/json/convert-to-object.test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { convertToObject } from '../../../src/utils/json.js'; -import { assert, test } from '../../helpers/testing.js'; - -test('utils | json | convert-to-object', function () { - const devDependencies = new Map([ - ['@embroider/compat', '^2.1.1'], - ['@embroider/core', '^2.1.1'], - ['@glint/core', '^v1.0.0-beta.4'], - ['@glint/environment-ember-loose', '^v1.0.0-beta.4'], - ['@glint/template', '^v1.0.0-beta.4'], - ['ember-css-modules', '^2.0.1'], - ['typescript', '^5.0.3'], - ]); - - const expectedValue = { - '@embroider/compat': '^2.1.1', - '@embroider/core': '^2.1.1', - '@glint/core': '^v1.0.0-beta.4', - '@glint/environment-ember-loose': '^v1.0.0-beta.4', - '@glint/template': '^v1.0.0-beta.4', - 'ember-css-modules': '^2.0.1', - typescript: '^5.0.3', - }; - - assert.deepEqual(convertToObject(devDependencies), expectedValue); -}); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/camelize.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/camelize.test.js index ff16d1cb..ed55a389 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/camelize.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/camelize.test.js @@ -1,6 +1,7 @@ /* https://github.com/ember-cli/ember-cli-string-utils/blob/v1.1.0/test.js */ +import { assert, test } from '@codemod-utils/tests'; + import { camelize } from '../../../../src/utils/string.js'; -import { assert, test } from '../../../helpers/testing.js'; test('utils | string | ember-cli-string-utils | camelize', function () { assert.strictEqual(camelize(''), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/classify.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/classify.test.js index ce929f3d..fb40a5a0 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/classify.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/ember-cli-string-utils/classify.test.js @@ -1,6 +1,7 @@ /* https://github.com/ember-cli/ember-cli-string-utils/blob/v1.1.0/test.js */ +import { assert, test } from '@codemod-utils/tests'; + import { classify } from '../../../../src/utils/string.js'; -import { assert, test } from '../../../helpers/testing.js'; test('utils | string | ember-cli-string-utils | classify', function () { assert.strictEqual(classify(''), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/classify.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/classify.test.js index 5d60c464..995ec160 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/classify.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/classify.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { classifyEntityName } from '../../../../src/utils/string.js'; -import { assert, test } from '../../../helpers/testing.js'; test('utils | string | entity-name | classifyEntityName', function () { assert.strictEqual(classifyEntityName(''), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/double-colonize.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/double-colonize.test.js index 4cd7482a..a5f69b6a 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/double-colonize.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/double-colonize.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { doubleColonizeEntityName } from '../../../../src/utils/string.js'; -import { assert, test } from '../../../helpers/testing.js'; test('utils | string | entity-name | double-doubleColonizeEntityName', function () { assert.strictEqual(doubleColonizeEntityName(''), ''); diff --git a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/parse.test.js b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/parse.test.js index 8f1a89be..9dddeb91 100644 --- a/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/parse.test.js +++ b/packages/ember-codemod-remove-ember-css-modules/tests/utils/string/entity-name/parse.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { parseEntityName } from '../../../../src/utils/string.js'; -import { assert, test } from '../../../helpers/testing.js'; test('utils | string | entity-name | parseEntityName', function () { assert.deepStrictEqual(parseEntityName(''), { diff --git a/packages/type-css-modules/package.json b/packages/type-css-modules/package.json index 292e965d..7fdcb209 100644 --- a/packages/type-css-modules/package.json +++ b/packages/type-css-modules/package.json @@ -29,13 +29,14 @@ "test": "mt tests --quiet" }, "dependencies": { + "@codemod-utils/files": "^0.1.0", "css-tree": "^2.3.1", - "glob": "^10.2.2", "yargs": "^17.7.2" }, "devDependencies": { "@babel/core": "^7.21.5", "@babel/eslint-parser": "^7.21.3", + "@codemod-utils/tests": "^0.1.0", "@sondr3/minitest": "^0.1.1", "eslint": "^8.39.0", "eslint-config-prettier": "^8.8.0", @@ -43,7 +44,6 @@ "eslint-plugin-n": "^15.7.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-simple-import-sort": "^10.0.0", - "fixturify": "^3.0.0", "prettier": "^2.8.8" }, "engines": { diff --git a/packages/type-css-modules/src/steps/clean-declaration-files.js b/packages/type-css-modules/src/steps/clean-declaration-files.js index a06586f7..0648a362 100644 --- a/packages/type-css-modules/src/steps/clean-declaration-files.js +++ b/packages/type-css-modules/src/steps/clean-declaration-files.js @@ -1,5 +1,6 @@ +import { findFiles, removeFiles, unionize } from '@codemod-utils/files'; + import { getCssDeclarationFilePaths } from '../utils/css.js'; -import { findFiles, removeFiles, unionize } from '../utils/files.js'; export function cleanDeclarationFiles(options) { const { projectRoot } = options; diff --git a/packages/type-css-modules/src/steps/create-declaration-files.js b/packages/type-css-modules/src/steps/create-declaration-files.js index d2274f1e..9ec8f443 100644 --- a/packages/type-css-modules/src/steps/create-declaration-files.js +++ b/packages/type-css-modules/src/steps/create-declaration-files.js @@ -1,9 +1,10 @@ +import { createFiles, findFiles, unionize } from '@codemod-utils/files'; + import { getClassNames, getCssFilePaths, getDeclarationFile, } from '../utils/css.js'; -import { createFiles, findFiles, unionize } from '../utils/files.js'; export function createDeclarationFiles(options) { const { projectRoot } = options; diff --git a/packages/type-css-modules/src/utils/files.js b/packages/type-css-modules/src/utils/files.js deleted file mode 100644 index bce1ea7c..00000000 --- a/packages/type-css-modules/src/utils/files.js +++ /dev/null @@ -1,4 +0,0 @@ -export * from './files/create-files.js'; -export * from './files/find-files.js'; -export * from './files/remove-directory-if-empty.js'; -export * from './files/remove-files.js'; diff --git a/packages/type-css-modules/src/utils/files/create-files.js b/packages/type-css-modules/src/utils/files/create-files.js deleted file mode 100644 index fb9b1c4e..00000000 --- a/packages/type-css-modules/src/utils/files/create-files.js +++ /dev/null @@ -1,17 +0,0 @@ -import { existsSync, mkdirSync, writeFileSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -export function createFiles(fileMapping, options) { - const { projectRoot } = options; - - fileMapping.forEach((file, newPath) => { - const newAbsolutePath = join(projectRoot, newPath); - const newDirectory = dirname(newAbsolutePath); - - if (!existsSync(newDirectory)) { - mkdirSync(newDirectory, { recursive: true }); - } - - writeFileSync(newAbsolutePath, file, 'utf8'); - }); -} diff --git a/packages/type-css-modules/src/utils/files/find-files.js b/packages/type-css-modules/src/utils/files/find-files.js deleted file mode 100644 index d2384bba..00000000 --- a/packages/type-css-modules/src/utils/files/find-files.js +++ /dev/null @@ -1,28 +0,0 @@ -import { globSync } from 'glob'; - -export function findFiles(pattern, { cwd, ignoreList = [] }) { - if (!pattern) { - throw new RangeError('ERROR: The glob pattern is unknown.\n'); - } - - if (!cwd) { - throw new RangeError('ERROR: The current working directory is unknown.\n'); - } - - const filePaths = globSync(pattern, { - cwd, - dot: true, - ignore: ignoreList, - nodir: true, - }); - - return filePaths; -} - -export function unionize(files) { - if (files.length <= 1) { - return files.join(','); - } - - return `{${files.join(',')}}`; -} diff --git a/packages/type-css-modules/src/utils/files/remove-directory-if-empty.js b/packages/type-css-modules/src/utils/files/remove-directory-if-empty.js deleted file mode 100644 index cac449f4..00000000 --- a/packages/type-css-modules/src/utils/files/remove-directory-if-empty.js +++ /dev/null @@ -1,19 +0,0 @@ -import { readdirSync, rmSync } from 'node:fs'; -import { dirname, join } from 'node:path'; - -export function removeDirectoryIfEmpty({ oldPath, projectRoot }) { - const directories = dirname(oldPath).split('/'); - const depth = directories.length; - - for (let i = 0; i < depth; i++) { - const directory = join(projectRoot, ...directories); - const numFilesLeft = readdirSync(directory).length; - - if (numFilesLeft > 0) { - continue; - } - - rmSync(directory, { recursive: true }); - directories.pop(); - } -} diff --git a/packages/type-css-modules/src/utils/files/remove-files.js b/packages/type-css-modules/src/utils/files/remove-files.js deleted file mode 100644 index 7838fc2f..00000000 --- a/packages/type-css-modules/src/utils/files/remove-files.js +++ /dev/null @@ -1,15 +0,0 @@ -import { rmSync } from 'node:fs'; -import { join } from 'node:path'; - -import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js'; - -export function removeFiles(oldPaths, options) { - const { projectRoot } = options; - - oldPaths.forEach((oldPath) => { - const oldAbsolutePath = join(projectRoot, oldPath); - - rmSync(oldAbsolutePath); - removeDirectoryIfEmpty({ oldPath, projectRoot }); - }); -} diff --git a/packages/type-css-modules/tests/fixtures/ember-app-flat/index.js b/packages/type-css-modules/tests/fixtures/ember-app-flat/index.js index 42105a86..e4514e72 100644 --- a/packages/type-css-modules/tests/fixtures/ember-app-flat/index.js +++ b/packages/type-css-modules/tests/fixtures/ember-app-flat/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-app-flat/input'); const outputProject = convertFixtureToJson('ember-app-flat/output'); diff --git a/packages/type-css-modules/tests/fixtures/ember-app-nested/index.js b/packages/type-css-modules/tests/fixtures/ember-app-nested/index.js index daa49eab..0074aa02 100644 --- a/packages/type-css-modules/tests/fixtures/ember-app-nested/index.js +++ b/packages/type-css-modules/tests/fixtures/ember-app-nested/index.js @@ -1,4 +1,4 @@ -import { convertFixtureToJson } from '../../helpers/testing.js'; +import { convertFixtureToJson } from '@codemod-utils/tests'; const inputProject = convertFixtureToJson('ember-app-nested/input'); const outputProject = convertFixtureToJson('ember-app-nested/output'); diff --git a/packages/type-css-modules/tests/helpers/testing.js b/packages/type-css-modules/tests/helpers/testing.js deleted file mode 100644 index b921c7a8..00000000 --- a/packages/type-css-modules/tests/helpers/testing.js +++ /dev/null @@ -1,9 +0,0 @@ -import { strict as assert } from 'node:assert'; - -import { test } from '@sondr3/minitest'; - -export { assert, test }; - -export * from './testing/assert-fixture.js'; -export * from './testing/convert-fixture-to-json.js'; -export * from './testing/load-fixture.js'; diff --git a/packages/type-css-modules/tests/helpers/testing/assert-fixture.js b/packages/type-css-modules/tests/helpers/testing/assert-fixture.js deleted file mode 100644 index ac6ca282..00000000 --- a/packages/type-css-modules/tests/helpers/testing/assert-fixture.js +++ /dev/null @@ -1,9 +0,0 @@ -import { strict as assert } from 'node:assert'; - -import fixturify from 'fixturify'; - -export function assertFixture(outputProject, codemodOptions) { - const { projectRoot } = codemodOptions; - - assert.deepStrictEqual(fixturify.readSync(projectRoot), outputProject); -} diff --git a/packages/type-css-modules/tests/helpers/testing/convert-fixture-to-json.js b/packages/type-css-modules/tests/helpers/testing/convert-fixture-to-json.js deleted file mode 100644 index cead0660..00000000 --- a/packages/type-css-modules/tests/helpers/testing/convert-fixture-to-json.js +++ /dev/null @@ -1,48 +0,0 @@ -import { readFileSync } from 'node:fs'; -import { join } from 'node:path'; - -import { globSync } from 'glob'; - -function updateJson(json, { currentDirectory, keys }) { - const key = keys.shift(); - const isFile = keys.length === 0; - - if (isFile) { - json[key] = readFileSync(join(currentDirectory, key), 'utf8'); - - return; - } - - if (!(key in json)) { - json[key] = {}; - } - - updateJson(json[key], { - currentDirectory: join(currentDirectory, key), - keys, - }); -} - -function createJson(filePaths = [], currentDirectory) { - const json = {}; - - filePaths.forEach((filePath) => { - const keys = filePath.split('/'); - - updateJson(json, { currentDirectory, keys }); - }); - - return json; -} - -export function convertFixtureToJson(projectRoot) { - const currentDirectory = `${process.cwd()}/tests/fixtures/${projectRoot}`; - - const filePaths = globSync('**/*', { - cwd: currentDirectory, - dot: true, - nodir: true, - }); - - return createJson(filePaths, currentDirectory); -} diff --git a/packages/type-css-modules/tests/helpers/testing/load-fixture.js b/packages/type-css-modules/tests/helpers/testing/load-fixture.js deleted file mode 100644 index 471fd425..00000000 --- a/packages/type-css-modules/tests/helpers/testing/load-fixture.js +++ /dev/null @@ -1,13 +0,0 @@ -import { existsSync, rmSync } from 'node:fs'; - -import fixturify from 'fixturify'; - -export function loadFixture(inputProject, codemodOptions) { - const { projectRoot } = codemodOptions; - - if (existsSync(projectRoot)) { - rmSync(projectRoot, { recursive: true }); - } - - fixturify.writeSync(projectRoot, inputProject); -} diff --git a/packages/type-css-modules/tests/index/ember-app-flat.test.js b/packages/type-css-modules/tests/index/ember-app-flat.test.js index e8e1f39c..91f63c65 100644 --- a/packages/type-css-modules/tests/index/ember-app-flat.test.js +++ b/packages/type-css-modules/tests/index/ember-app-flat.test.js @@ -1,10 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { typeCssModules } from '../../src/index.js'; import { inputProject, outputProject, } from '../fixtures/ember-app-flat/index.js'; import { codemodOptions } from '../helpers/shared-test-setups/ember-app-flat.js'; -import { assertFixture, loadFixture, test } from '../helpers/testing.js'; test('index > ember-app-flat', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/type-css-modules/tests/index/ember-app-nested.test.js b/packages/type-css-modules/tests/index/ember-app-nested.test.js index 967b97ac..0b168af8 100644 --- a/packages/type-css-modules/tests/index/ember-app-nested.test.js +++ b/packages/type-css-modules/tests/index/ember-app-nested.test.js @@ -1,10 +1,11 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + import { typeCssModules } from '../../src/index.js'; import { inputProject, outputProject, } from '../fixtures/ember-app-nested/index.js'; import { codemodOptions } from '../helpers/shared-test-setups/ember-app-nested.js'; -import { assertFixture, loadFixture, test } from '../helpers/testing.js'; test('index > ember-app-nested', function () { loadFixture(inputProject, codemodOptions); diff --git a/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-flat.test.js b/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-flat.test.js index 17db8ed7..6235f322 100644 --- a/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-flat.test.js +++ b/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-flat.test.js @@ -1,14 +1,15 @@ -import { cleanDeclarationFiles } from '../../../src/steps/index.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { cleanDeclarationFiles } from '../../../src/steps/index.js'; +import { + codemodOptions, + options, +} from '../../helpers/shared-test-setups/ember-app-flat.js'; test('steps | clean-declaration-files > ember-app-flat', function () { const inputProject = convertFixtureToJson( diff --git a/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-nested.test.js b/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-nested.test.js index 8aa95ba2..7639d3a7 100644 --- a/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-nested.test.js +++ b/packages/type-css-modules/tests/steps/clean-declaration-files/ember-app-nested.test.js @@ -1,14 +1,15 @@ -import { cleanDeclarationFiles } from '../../../src/steps/index.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-nested.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { cleanDeclarationFiles } from '../../../src/steps/index.js'; +import { + codemodOptions, + options, +} from '../../helpers/shared-test-setups/ember-app-nested.js'; test('steps | clean-declaration-files > ember-app-nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-flat.test.js b/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-flat.test.js index 9db47a22..74352d4d 100644 --- a/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-flat.test.js +++ b/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-flat.test.js @@ -1,14 +1,15 @@ -import { createDeclarationFiles } from '../../../src/steps/index.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { createDeclarationFiles } from '../../../src/steps/index.js'; +import { + codemodOptions, + options, +} from '../../helpers/shared-test-setups/ember-app-flat.js'; test('steps | create-declaration-files > ember-app-flat', function () { const inputProject = convertFixtureToJson( diff --git a/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-nested.test.js b/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-nested.test.js index 10556db5..5243af9e 100644 --- a/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-nested.test.js +++ b/packages/type-css-modules/tests/steps/create-declaration-files/ember-app-nested.test.js @@ -1,14 +1,15 @@ -import { createDeclarationFiles } from '../../../src/steps/index.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-nested.js'; import { assertFixture, convertFixtureToJson, loadFixture, test, -} from '../../helpers/testing.js'; +} from '@codemod-utils/tests'; + +import { createDeclarationFiles } from '../../../src/steps/index.js'; +import { + codemodOptions, + options, +} from '../../helpers/shared-test-setups/ember-app-nested.js'; test('steps | create-declaration-files > ember-app-nested', function () { const inputProject = convertFixtureToJson( diff --git a/packages/type-css-modules/tests/steps/create-options/ember-app-flat.test.js b/packages/type-css-modules/tests/steps/create-options/ember-app-flat.test.js index aa99e6a3..25e38e94 100644 --- a/packages/type-css-modules/tests/steps/create-options/ember-app-flat.test.js +++ b/packages/type-css-modules/tests/steps/create-options/ember-app-flat.test.js @@ -1,6 +1,7 @@ +import { assert, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../src/steps/index.js'; import { codemodOptions } from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assert, test } from '../../helpers/testing.js'; test('steps | create-options > ember-app-flat', function () { assert.deepStrictEqual(createOptions(codemodOptions), { diff --git a/packages/type-css-modules/tests/steps/create-options/ember-app-nested.test.js b/packages/type-css-modules/tests/steps/create-options/ember-app-nested.test.js index 25442b4d..7ee97c93 100644 --- a/packages/type-css-modules/tests/steps/create-options/ember-app-nested.test.js +++ b/packages/type-css-modules/tests/steps/create-options/ember-app-nested.test.js @@ -1,6 +1,7 @@ +import { assert, test } from '@codemod-utils/tests'; + import { createOptions } from '../../../src/steps/index.js'; import { codemodOptions } from '../../helpers/shared-test-setups/ember-app-nested.js'; -import { assert, test } from '../../helpers/testing.js'; test('steps | create-options > ember-app-nested', function () { assert.deepStrictEqual(createOptions(codemodOptions), { diff --git a/packages/type-css-modules/tests/utils/abstract-syntax-tree/css.test.js b/packages/type-css-modules/tests/utils/abstract-syntax-tree/css.test.js index 72a2b14b..c7520bb7 100644 --- a/packages/type-css-modules/tests/utils/abstract-syntax-tree/css.test.js +++ b/packages/type-css-modules/tests/utils/abstract-syntax-tree/css.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { ASTCSS as AST } from '../../../src/utils/abstract-syntax-tree.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | abstract-syntax-tree | css > file is empty', function () { const oldFile = ''; diff --git a/packages/type-css-modules/tests/utils/css/get-class-names.test.js b/packages/type-css-modules/tests/utils/css/get-class-names.test.js index 5c7507ca..a2a4192f 100644 --- a/packages/type-css-modules/tests/utils/css/get-class-names.test.js +++ b/packages/type-css-modules/tests/utils/css/get-class-names.test.js @@ -1,9 +1,10 @@ +import { assert, loadFixture, test } from '@codemod-utils/tests'; + import { getClassNames } from '../../../src/utils/css.js'; import { codemodOptions, options, } from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assert, loadFixture, test } from '../../helpers/testing.js'; test('utils | css | get-class-names > base case (1)', function () { const cssFile = [ diff --git a/packages/type-css-modules/tests/utils/css/get-css-declaration-file-paths.test.js b/packages/type-css-modules/tests/utils/css/get-css-declaration-file-paths.test.js index e8790cc2..a2cf590f 100644 --- a/packages/type-css-modules/tests/utils/css/get-css-declaration-file-paths.test.js +++ b/packages/type-css-modules/tests/utils/css/get-css-declaration-file-paths.test.js @@ -1,6 +1,7 @@ +import { assert, test } from '@codemod-utils/tests'; + import { getCssDeclarationFilePaths } from '../../../src/utils/css.js'; import { options } from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | css | get-css-declaration-file-paths', function () { assert.deepStrictEqual(getCssDeclarationFilePaths(options), [ diff --git a/packages/type-css-modules/tests/utils/css/get-css-file-paths.test.js b/packages/type-css-modules/tests/utils/css/get-css-file-paths.test.js index bb71797b..13a48810 100644 --- a/packages/type-css-modules/tests/utils/css/get-css-file-paths.test.js +++ b/packages/type-css-modules/tests/utils/css/get-css-file-paths.test.js @@ -1,6 +1,7 @@ +import { assert, test } from '@codemod-utils/tests'; + import { getCssFilePaths } from '../../../src/utils/css.js'; import { options } from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | css | get-css-file-paths', function () { assert.deepStrictEqual(getCssFilePaths(options), ['app/**/*.css']); diff --git a/packages/type-css-modules/tests/utils/css/get-declaration-file.test.js b/packages/type-css-modules/tests/utils/css/get-declaration-file.test.js index b38f1765..206d73c8 100644 --- a/packages/type-css-modules/tests/utils/css/get-declaration-file.test.js +++ b/packages/type-css-modules/tests/utils/css/get-declaration-file.test.js @@ -1,5 +1,6 @@ +import { assert, test } from '@codemod-utils/tests'; + import { getDeclarationFile } from '../../../src/utils/css.js'; -import { assert, test } from '../../helpers/testing.js'; test('utils | css | get-declaration-file > base case', function () { const classNames = ['copyright', 'has-error', 'link', 'list']; diff --git a/packages/type-css-modules/tests/utils/files/create-files.test.js b/packages/type-css-modules/tests/utils/files/create-files.test.js deleted file mode 100644 index ae637edd..00000000 --- a/packages/type-css-modules/tests/utils/files/create-files.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import { createFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | create-files', function () { - const inputProject = {}; - - const outputProject = { - app: { - components: { - ui: { - 'page.css.d.ts': 'some code for page.css.d.ts', - }, - 'navigation-menu.css.d.ts': 'some code for navigation-menu.css.d.ts', - }, - routes: { - 'application.css.d.ts': 'some code for application.css.d.ts', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const fileMapping = new Map([ - [ - 'app/components/navigation-menu.css.d.ts', - 'some code for navigation-menu.css.d.ts', - ], - ['app/components/ui/page.css.d.ts', 'some code for page.css.d.ts'], - ['app/routes/application.css.d.ts', 'some code for application.css.d.ts'], - ]); - - createFiles(fileMapping, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/type-css-modules/tests/utils/files/find-files.test.js b/packages/type-css-modules/tests/utils/files/find-files.test.js deleted file mode 100644 index 04881070..00000000 --- a/packages/type-css-modules/tests/utils/files/find-files.test.js +++ /dev/null @@ -1,61 +0,0 @@ -import { findFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assert, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | find-files', function () { - const inputProject = { - app: { - components: { - ui: { - 'page.css': '', - 'page.css.d.ts': '', - 'page.hbs': '', - 'page.ts': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.css.d.ts': '', - 'navigation-menu.hbs': '', - 'navigation-menu.ts': '', - }, - routes: { - 'application.css': '', - 'application.css.d.ts': '', - }, - }, - node_modules: { - 'ember-container-query': { - dist: { - components: { - 'container-query.css': '', - }, - }, - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - let filePaths = findFiles('app/**/*.css', { - cwd: options.projectRoot, - }); - - assert.deepStrictEqual(filePaths.sort(), [ - 'app/components/navigation-menu.css', - 'app/components/ui/page.css', - 'app/routes/application.css', - ]); - - filePaths = findFiles('**/*.css', { - cwd: options.projectRoot, - ignoreList: ['node_modules/**/*'], - }); - - assert.deepStrictEqual(filePaths.sort(), [ - 'app/components/navigation-menu.css', - 'app/components/ui/page.css', - 'app/routes/application.css', - ]); -}); diff --git a/packages/type-css-modules/tests/utils/files/remove-directory-if-empty.test.js b/packages/type-css-modules/tests/utils/files/remove-directory-if-empty.test.js deleted file mode 100644 index 41b2f3bd..00000000 --- a/packages/type-css-modules/tests/utils/files/remove-directory-if-empty.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import { removeDirectoryIfEmpty } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | remove-directory-if-empty > parent directories are empty', function () { - const inputProject = { - app: { - components: {}, - }, - }; - - const outputProject = {}; - - loadFixture(inputProject, codemodOptions); - - removeDirectoryIfEmpty({ - oldPath: 'app/components/navigation-menu.css.d.ts', - projectRoot: options.projectRoot, - }); - - assertFixture(outputProject, codemodOptions); -}); - -test('utils | files | remove-directory-if-empty > a parent directory is not empty', function () { - const inputProject = { - app: { - components: {}, - '.gitkeep': '', - }, - }; - - const outputProject = { - app: { - '.gitkeep': '', - }, - }; - - loadFixture(inputProject, codemodOptions); - - removeDirectoryIfEmpty({ - oldPath: 'app/components/navigation-menu.css.d.ts', - projectRoot: options.projectRoot, - }); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/packages/type-css-modules/tests/utils/files/remove-files.test.js b/packages/type-css-modules/tests/utils/files/remove-files.test.js deleted file mode 100644 index b5094b11..00000000 --- a/packages/type-css-modules/tests/utils/files/remove-files.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import { removeFiles } from '../../../src/utils/files.js'; -import { - codemodOptions, - options, -} from '../../helpers/shared-test-setups/ember-app-flat.js'; -import { assertFixture, loadFixture, test } from '../../helpers/testing.js'; - -test('utils | files | remove-files', function () { - const inputProject = { - app: { - components: { - ui: { - 'page.css': '', - 'page.css.d.ts': '', - 'page.hbs': '', - 'page.ts': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.css.d.ts': '', - 'navigation-menu.hbs': '', - 'navigation-menu.ts': '', - }, - routes: { - 'application.css': '', - 'application.css.d.ts': '', - }, - }, - }; - - const outputProject = { - app: { - components: { - ui: { - 'page.css': '', - 'page.hbs': '', - 'page.ts': '', - }, - 'navigation-menu.css': '', - 'navigation-menu.hbs': '', - 'navigation-menu.ts': '', - }, - routes: { - 'application.css': '', - }, - }, - }; - - loadFixture(inputProject, codemodOptions); - - const filePaths = [ - 'app/components/navigation-menu.css.d.ts', - 'app/components/ui/page.css.d.ts', - 'app/routes/application.css.d.ts', - ]; - - removeFiles(filePaths, options); - - assertFixture(outputProject, codemodOptions); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index deb50755..6946e96a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -530,15 +530,18 @@ importers: '@babel/parser': specifier: ^7.21.5 version: 7.21.5 + '@codemod-utils/blueprints': + specifier: ^0.1.1 + version: 0.1.1 + '@codemod-utils/files': + specifier: ^0.1.0 + version: 0.1.0 + '@codemod-utils/json': + specifier: ^0.1.1 + version: 0.1.1 ember-template-recast: specifier: ^6.1.4 version: 6.1.4 - glob: - specifier: ^10.2.2 - version: 10.2.2 - lodash.template: - specifier: ^4.5.0 - version: 4.5.0 recast: specifier: ^0.23.1 version: 0.23.1 @@ -552,6 +555,9 @@ importers: '@babel/eslint-parser': specifier: ^7.21.3 version: 7.21.3(@babel/core@7.21.5)(eslint@8.39.0) + '@codemod-utils/tests': + specifier: ^0.1.0 + version: 0.1.0(@sondr3/minitest@0.1.1) '@sondr3/minitest': specifier: ^0.1.1 version: 0.1.1 @@ -573,9 +579,6 @@ importers: eslint-plugin-simple-import-sort: specifier: ^10.0.0 version: 10.0.0(eslint@8.39.0) - fixturify: - specifier: ^3.0.0 - version: 3.0.0 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -764,12 +767,12 @@ importers: packages/type-css-modules: dependencies: + '@codemod-utils/files': + specifier: ^0.1.0 + version: 0.1.0 css-tree: specifier: ^2.3.1 version: 2.3.1 - glob: - specifier: ^10.2.2 - version: 10.2.2 yargs: specifier: ^17.7.2 version: 17.7.2 @@ -780,6 +783,9 @@ importers: '@babel/eslint-parser': specifier: ^7.21.3 version: 7.21.3(@babel/core@7.21.5)(eslint@8.39.0) + '@codemod-utils/tests': + specifier: ^0.1.0 + version: 0.1.0(@sondr3/minitest@0.1.1) '@sondr3/minitest': specifier: ^0.1.1 version: 0.1.1 @@ -801,9 +807,6 @@ importers: eslint-plugin-simple-import-sort: specifier: ^10.0.0 version: 10.0.0(eslint@8.39.0) - fixturify: - specifier: ^3.0.0 - version: 3.0.0 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -2660,6 +2663,36 @@ packages: minimist: 1.2.8 dev: true + /@codemod-utils/blueprints@0.1.1: + resolution: {integrity: sha512-JGtAarSCTR4/6MGegfaOglRCaY2JYO8A+o6Wz83vMUyp6teVEtVoxDkB88jD4gtheuZLkRKI8LH5VD+grWasjQ==} + engines: {node: 16.* || >= 18} + dependencies: + lodash.template: 4.5.0 + dev: false + + /@codemod-utils/files@0.1.0: + resolution: {integrity: sha512-a1QLQ4TFS1hDrLwroXMVlOQiqu9MCbzUoEk+NBiLxjK1FkSQr6hQisI7wEePClCjm7zdEqyt3f0uRlljD7bOcg==} + engines: {node: 16.* || >= 18} + dependencies: + glob: 10.2.4 + dev: false + + /@codemod-utils/json@0.1.1: + resolution: {integrity: sha512-II6DvRSbQzjMBp1ZJcTIUNyyDYg1RIPqAOnik1Tke4WF12TyeUa5Hw64ujBlF6CjtVtyJBfMrtq7jHsbGm1MLQ==} + engines: {node: 16.* || >= 18} + dev: false + + /@codemod-utils/tests@0.1.0(@sondr3/minitest@0.1.1): + resolution: {integrity: sha512-4iDXxaalD5AKVo4TTWnEqkRecCTMvzm8haWkWFJlrHDJ8ZewIDMnU2XvV8Bd/nfFC2swM+er5zWZUPozL7AazQ==} + engines: {node: 16.* || >= 18} + peerDependencies: + '@sondr3/minitest': ^0.1.1 + dependencies: + '@sondr3/minitest': 0.1.1 + fixturify: 3.0.0 + glob: 10.2.4 + dev: true + /@colors/colors@1.5.0: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -3614,7 +3647,6 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} requiresBuild: true - dev: false optional: true /@rollup/pluginutils@4.2.1: @@ -9791,7 +9823,6 @@ packages: dependencies: cross-spawn: 7.0.3 signal-exit: 4.0.1 - dev: false /form-data@3.0.1: resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} @@ -10076,8 +10107,8 @@ packages: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} dev: true - /glob@10.2.2: - resolution: {integrity: sha512-Xsa0BcxIC6th9UwNjZkhrMtNo/MnyRL8jGCP+uEwhA5oFOCY1f2s1/oNKY47xQ0Bg5nkjsfAEIej1VeH62bDDQ==} + /glob@10.2.4: + resolution: {integrity: sha512-fDboBse/sl1oXSLhIp0FcCJgzW9KmhC/q8ULTKC82zc+DL3TL7FNb8qlt5qqXN53MsKEUSIcb+7DLmEygOE5Yw==} engines: {node: '>=16 || 14 >=14.17'} hasBin: true dependencies: @@ -10086,7 +10117,6 @@ packages: minimatch: 9.0.0 minipass: 5.0.0 path-scurry: 1.7.0 - dev: false /glob@5.0.15: resolution: {integrity: sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==} @@ -11174,7 +11204,6 @@ packages: cliui: 7.0.4 optionalDependencies: '@pkgjs/parseargs': 0.11.0 - dev: false /jest-worker@27.5.1: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} @@ -11763,7 +11792,6 @@ packages: /lru-cache@9.1.1: resolution: {integrity: sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A==} engines: {node: 14 || >=16.14} - dev: false /magic-string@0.25.9: resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} @@ -12066,7 +12094,6 @@ packages: engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 - dev: false /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} @@ -12095,7 +12122,6 @@ packages: /minipass@5.0.0: resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} engines: {node: '>=8'} - dev: false /mixin-deep@1.3.2: resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} @@ -12830,7 +12856,6 @@ packages: dependencies: lru-cache: 9.1.1 minipass: 5.0.0 - dev: false /path-to-regexp@0.1.7: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} @@ -14330,7 +14355,6 @@ packages: /signal-exit@4.0.1: resolution: {integrity: sha512-uUWsN4aOxJAS8KOuf3QMyFtgm1pkb6I+KRZbRF/ghdf5T7sM+B1lLLzPDxswUjkmHyxQAVzEgG35E3NzDM9GVw==} engines: {node: '>=14'} - dev: false /silent-error@1.1.1: resolution: {integrity: sha512-n4iEKyNcg4v6/jpb3c0/iyH2G1nzUNl7Gpqtn/mHIJK9S/q/7MCfoO4rwVOoO59qPFIc0hVHvMbiOJ0NdtxKKw==}