ember-codemod-remove-ember-css-modules 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -17
- package/src/migration/ember-app/steps/analyze-app.js +1 -1
- package/src/migration/ember-app/steps/move-stylesheets.js +1 -1
- package/src/migration/ember-app/steps/shared/import-styles.js +5 -6
- package/src/migration/ember-app/steps/shared/update-templates.js +2 -1
- package/src/migration/ember-app/steps/update-app-app-js.js +2 -1
- package/src/migration/ember-app/steps/update-package-json.js +4 -3
- package/src/utils/blueprints/blueprints-root.js +8 -0
- package/src/utils/blueprints/get-version.js +16 -0
- package/src/utils/blueprints.js +2 -3
- package/src/utils/blueprints/blueprint-root.js +0 -13
- package/src/utils/blueprints/decide-version.js +0 -25
- package/src/utils/blueprints/process-template.js +0 -12
- package/src/utils/files/copy-files.js +0 -19
- package/src/utils/files/create-files.js +0 -17
- package/src/utils/files/find-files.js +0 -28
- package/src/utils/files/map-file-paths.js +0 -25
- package/src/utils/files/move-files.js +0 -22
- package/src/utils/files/remove-directory-if-empty.js +0 -19
- package/src/utils/files/remove-files.js +0 -15
- package/src/utils/files.js +0 -7
- package/src/utils/json/convert-to-map.js +0 -3
- package/src/utils/json/convert-to-object.js +0 -5
- package/src/utils/json.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-remove-ember-css-modules",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Codemod to replace ember-css-modules with embroider-css-modules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -27,32 +27,31 @@
|
|
|
27
27
|
"test": "tests"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/parser": "^7.21.
|
|
30
|
+
"@babel/parser": "^7.21.9",
|
|
31
|
+
"@codemod-utils/blueprints": "^0.1.1",
|
|
32
|
+
"@codemod-utils/files": "^0.1.0",
|
|
33
|
+
"@codemod-utils/json": "^0.1.1",
|
|
31
34
|
"ember-template-recast": "^6.1.4",
|
|
32
|
-
"
|
|
33
|
-
"lodash.template": "^4.5.0",
|
|
34
|
-
"recast": "^0.23.1",
|
|
35
|
+
"recast": "^0.23.2",
|
|
35
36
|
"yargs": "^17.7.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@babel/eslint-parser": "^7.21.3",
|
|
39
|
+
"@codemod-utils/tests": "^0.1.0",
|
|
40
40
|
"@sondr3/minitest": "^0.1.1",
|
|
41
|
-
"
|
|
42
|
-
"eslint
|
|
43
|
-
"
|
|
44
|
-
"eslint-
|
|
45
|
-
"
|
|
46
|
-
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
47
|
-
"fixturify": "^3.0.0",
|
|
48
|
-
"prettier": "^2.8.8"
|
|
41
|
+
"concurrently": "^8.0.1",
|
|
42
|
+
"eslint": "^8.41.0",
|
|
43
|
+
"prettier": "^2.8.8",
|
|
44
|
+
"@shared-configs/eslint-config": "0.0.0",
|
|
45
|
+
"@shared-configs/prettier": "0.0.0"
|
|
49
46
|
},
|
|
50
47
|
"engines": {
|
|
51
48
|
"node": "16.* || >= 18"
|
|
52
49
|
},
|
|
53
50
|
"scripts": {
|
|
54
|
-
"lint": "
|
|
55
|
-
"lint:fix": "
|
|
51
|
+
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
|
|
52
|
+
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
|
|
53
|
+
"lint:js": "eslint . --cache",
|
|
54
|
+
"lint:js:fix": "eslint . --fix",
|
|
56
55
|
"test": "mt tests --quiet"
|
|
57
56
|
}
|
|
58
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join, parse } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import { findFiles, renameDirectory } from '
|
|
3
|
+
import { findFiles, renameDirectory } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
function findAndRenameFiles(findOptions, replaceOptions) {
|
|
6
6
|
const { globPattern, ignoreList, projectRoot } = findOptions;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join, parse } from 'node:path';
|
|
3
3
|
|
|
4
|
+
import { processTemplate } from '@codemod-utils/blueprints';
|
|
5
|
+
import { createFiles } from '@codemod-utils/files';
|
|
6
|
+
|
|
4
7
|
import { ASTJavaScript as AST } from '../../../../utils/abstract-syntax-tree.js';
|
|
5
|
-
import {
|
|
6
|
-
blueprintRoot,
|
|
7
|
-
processTemplate,
|
|
8
|
-
} from '../../../../utils/blueprints.js';
|
|
9
|
-
import { createFiles } from '../../../../utils/files.js';
|
|
8
|
+
import { blueprintsRoot } from '../../../../utils/blueprints.js';
|
|
10
9
|
import { parseEntityName } from '../../../../utils/string.js';
|
|
11
10
|
|
|
12
11
|
function removeTemplateOnlyComponentMethod(file, data) {
|
|
@@ -134,7 +133,7 @@ function createClass(customizations, options) {
|
|
|
134
133
|
const fileMapping = new Map(
|
|
135
134
|
blueprintFilePaths.map((blueprintFilePath) => {
|
|
136
135
|
const blueprintFile = readFileSync(
|
|
137
|
-
join(
|
|
136
|
+
join(blueprintsRoot, blueprintFilePath),
|
|
138
137
|
'utf8',
|
|
139
138
|
);
|
|
140
139
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
+
import { createFiles } from '@codemod-utils/files';
|
|
5
|
+
|
|
4
6
|
import { ASTHandlebars as AST } from '../../../../utils/abstract-syntax-tree.js';
|
|
5
|
-
import { createFiles } from '../../../../utils/files.js';
|
|
6
7
|
|
|
7
8
|
function sanitizeClassAndLocalClassAttributes(file) {
|
|
8
9
|
function removeAttributeWithoutValue(attributeName, attributes) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { extname, join } from 'node:path';
|
|
3
3
|
|
|
4
|
+
import { createFiles, findFiles } from '@codemod-utils/files';
|
|
5
|
+
|
|
4
6
|
import { ASTJavaScript as AST } from '../../../utils/abstract-syntax-tree.js';
|
|
5
|
-
import { createFiles, findFiles } from '../../../utils/files.js';
|
|
6
7
|
|
|
7
8
|
function addCssEntryPoint(file, data) {
|
|
8
9
|
const traverse = AST.traverse(data.hasTypeScript);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { convertToMap, convertToObject } from '@codemod-utils/json';
|
|
5
|
+
|
|
6
|
+
import { getVersion } from '../../../utils/blueprints.js';
|
|
6
7
|
|
|
7
8
|
function updateDevDependencies(packageJson, options) {
|
|
8
9
|
const { project } = options;
|
|
@@ -22,7 +23,7 @@ function updateDevDependencies(packageJson, options) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
[...packagesToInstall].sort().forEach((packageName) => {
|
|
25
|
-
const version =
|
|
26
|
+
const version = getVersion(packageName, options);
|
|
26
27
|
|
|
27
28
|
devDependencies.set(packageName, version);
|
|
28
29
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decideVersion } from '@codemod-utils/blueprints';
|
|
2
|
+
|
|
3
|
+
const latestVersions = new Map([
|
|
4
|
+
['embroider-css-modules', '0.1.1'],
|
|
5
|
+
['type-css-modules', '0.1.1'],
|
|
6
|
+
['webpack', '5.81.0'],
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export function getVersion(packageName, options) {
|
|
10
|
+
const { project } = options;
|
|
11
|
+
|
|
12
|
+
return decideVersion(packageName, {
|
|
13
|
+
dependencies: project.dependencies,
|
|
14
|
+
latestVersions,
|
|
15
|
+
});
|
|
16
|
+
}
|
package/src/utils/blueprints.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './blueprints/
|
|
2
|
-
export * from './blueprints/
|
|
3
|
-
export * from './blueprints/process-template.js';
|
|
1
|
+
export * from './blueprints/blueprints-root.js';
|
|
2
|
+
export * from './blueprints/get-version.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { dirname, join } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
|
|
4
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = dirname(__filename);
|
|
6
|
-
|
|
7
|
-
function getBlueprintRoot() {
|
|
8
|
-
const srcDirectory = join(__dirname, '../..');
|
|
9
|
-
|
|
10
|
-
return join(srcDirectory, 'blueprints');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const blueprintRoot = getBlueprintRoot();
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const latestVersions = new Map([
|
|
2
|
-
['embroider-css-modules', '0.1.1'],
|
|
3
|
-
['type-css-modules', '0.1.1'],
|
|
4
|
-
['webpack', '5.81.0'],
|
|
5
|
-
]);
|
|
6
|
-
|
|
7
|
-
export function decideVersion(packageName, options) {
|
|
8
|
-
const { project } = options;
|
|
9
|
-
|
|
10
|
-
const installedVersion = project.dependencies.get(packageName);
|
|
11
|
-
|
|
12
|
-
if (installedVersion) {
|
|
13
|
-
return installedVersion;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const latestVersion = latestVersions.get(packageName);
|
|
17
|
-
|
|
18
|
-
if (!latestVersion) {
|
|
19
|
-
throw new RangeError(
|
|
20
|
-
`ERROR: The latest version of \`${packageName}\` is unknown.\n`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return `^${latestVersion}`;
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* https://github.com/ember-cli/ember-cli/blob/v4.11.0/lib/utilities/process-template.js */
|
|
2
|
-
import template from 'lodash.template';
|
|
3
|
-
|
|
4
|
-
export function processTemplate(file, data) {
|
|
5
|
-
const settings = {
|
|
6
|
-
escape: /<%-([\s\S]+?)%>/g,
|
|
7
|
-
evaluate: /<%([\s\S]+?)%>/g,
|
|
8
|
-
interpolate: /<%=([\s\S]+?)%>/g,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
return template(file, settings)(data);
|
|
12
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
export function copyFiles(pathMapping, options) {
|
|
5
|
-
const { projectRoot } = options;
|
|
6
|
-
|
|
7
|
-
pathMapping.forEach((newPath, oldPath) => {
|
|
8
|
-
const oldAbsolutePath = join(projectRoot, oldPath);
|
|
9
|
-
|
|
10
|
-
const newAbsolutePath = join(projectRoot, newPath);
|
|
11
|
-
const newDirectory = dirname(newAbsolutePath);
|
|
12
|
-
|
|
13
|
-
if (!existsSync(newDirectory)) {
|
|
14
|
-
mkdirSync(newDirectory, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
copyFileSync(oldAbsolutePath, newAbsolutePath);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
export function createFiles(fileMapping, options) {
|
|
5
|
-
const { projectRoot } = options;
|
|
6
|
-
|
|
7
|
-
fileMapping.forEach((file, newPath) => {
|
|
8
|
-
const newAbsolutePath = join(projectRoot, newPath);
|
|
9
|
-
const newDirectory = dirname(newAbsolutePath);
|
|
10
|
-
|
|
11
|
-
if (!existsSync(newDirectory)) {
|
|
12
|
-
mkdirSync(newDirectory, { recursive: true });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
writeFileSync(newAbsolutePath, file, 'utf8');
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { globSync } from 'glob';
|
|
2
|
-
|
|
3
|
-
export function findFiles(pattern, { cwd, ignoreList = [] }) {
|
|
4
|
-
if (!pattern) {
|
|
5
|
-
throw new RangeError('ERROR: The glob pattern is unknown.\n');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (!cwd) {
|
|
9
|
-
throw new RangeError('ERROR: The current working directory is unknown.\n');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const filePaths = globSync(pattern, {
|
|
13
|
-
cwd,
|
|
14
|
-
dot: true,
|
|
15
|
-
ignore: ignoreList,
|
|
16
|
-
nodir: true,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return filePaths;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function unionize(files) {
|
|
23
|
-
if (files.length <= 1) {
|
|
24
|
-
return files.join(',');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return `{${files.join(',')}}`;
|
|
28
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
|
|
3
|
-
export function renameDirectory(oldPath, { from, to }) {
|
|
4
|
-
if (from === '') {
|
|
5
|
-
return join(to, oldPath);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (!oldPath.startsWith(`${from}/`)) {
|
|
9
|
-
return oldPath;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return join(to, oldPath.replace(`${from}/`, ''));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function mapFilePaths(filePaths, directory) {
|
|
16
|
-
const { from, to } = directory;
|
|
17
|
-
|
|
18
|
-
return new Map(
|
|
19
|
-
filePaths.map((filePath) => {
|
|
20
|
-
const newPath = renameDirectory(filePath, { from, to });
|
|
21
|
-
|
|
22
|
-
return [filePath, newPath];
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, renameSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js';
|
|
5
|
-
|
|
6
|
-
export function moveFiles(pathMapping, options) {
|
|
7
|
-
const { projectRoot } = options;
|
|
8
|
-
|
|
9
|
-
pathMapping.forEach((newPath, oldPath) => {
|
|
10
|
-
const oldAbsolutePath = join(projectRoot, oldPath);
|
|
11
|
-
|
|
12
|
-
const newAbsolutePath = join(projectRoot, newPath);
|
|
13
|
-
const newDirectory = dirname(newAbsolutePath);
|
|
14
|
-
|
|
15
|
-
if (!existsSync(newDirectory)) {
|
|
16
|
-
mkdirSync(newDirectory, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
renameSync(oldAbsolutePath, newAbsolutePath);
|
|
20
|
-
removeDirectoryIfEmpty({ oldPath, projectRoot });
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
export function removeDirectoryIfEmpty({ oldPath, projectRoot }) {
|
|
5
|
-
const directories = dirname(oldPath).split('/');
|
|
6
|
-
const depth = directories.length;
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < depth; i++) {
|
|
9
|
-
const directory = join(projectRoot, ...directories);
|
|
10
|
-
const numFilesLeft = readdirSync(directory).length;
|
|
11
|
-
|
|
12
|
-
if (numFilesLeft > 0) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
rmSync(directory, { recursive: true });
|
|
17
|
-
directories.pop();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js';
|
|
5
|
-
|
|
6
|
-
export function removeFiles(oldPaths, options) {
|
|
7
|
-
const { projectRoot } = options;
|
|
8
|
-
|
|
9
|
-
oldPaths.forEach((oldPath) => {
|
|
10
|
-
const oldAbsolutePath = join(projectRoot, oldPath);
|
|
11
|
-
|
|
12
|
-
rmSync(oldAbsolutePath);
|
|
13
|
-
removeDirectoryIfEmpty({ oldPath, projectRoot });
|
|
14
|
-
});
|
|
15
|
-
}
|
package/src/utils/files.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './files/copy-files.js';
|
|
2
|
-
export * from './files/create-files.js';
|
|
3
|
-
export * from './files/find-files.js';
|
|
4
|
-
export * from './files/map-file-paths.js';
|
|
5
|
-
export * from './files/move-files.js';
|
|
6
|
-
export * from './files/remove-directory-if-empty.js';
|
|
7
|
-
export * from './files/remove-files.js';
|
package/src/utils/json.js
DELETED