ember-codemod-pod-to-octane 1.2.3 → 1.2.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-pod-to-octane",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "Codemod to un-pod Ember apps, addons, and engines",
5
5
  "keywords": [
6
6
  "codemod",
@@ -21,6 +21,7 @@
21
21
  "test": "tests"
22
22
  },
23
23
  "files": [
24
+ "blueprints",
24
25
  "dist"
25
26
  ],
26
27
  "dependencies": {
@@ -29,8 +30,7 @@
29
30
  },
30
31
  "devDependencies": {
31
32
  "@babel/core": "^7.22.5",
32
- "@babel/eslint-parser": "^7.22.5",
33
- "@codemod-utils/tests": "^0.2.1",
33
+ "@codemod-utils/tests": "^0.2.2",
34
34
  "@sondr3/minitest": "^0.1.1",
35
35
  "@tsconfig/esm": "^1.0.3",
36
36
  "@tsconfig/node16": "^1.0.4",
@@ -1,73 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- import { join, parse } from 'node:path';
3
- import { findFiles } from '@codemod-utils/files';
4
- function removeFileExtension(path) {
5
- const { dir, name } = parse(path);
6
- return `${dir}/${name}`;
7
- }
8
- function createMapping(migrationStrategy) {
9
- return new Map([...migrationStrategy].map(([oldPath, newPath]) => {
10
- const before = removeFileExtension(oldPath);
11
- const after = removeFileExtension(newPath);
12
- return [before, after];
13
- }));
14
- }
15
- function updatePathsToAddonFiles(oldFile, { mapping, projectName }) {
16
- const regex = new RegExp(`(?:'|")(${projectName}/(.*))(?:'|")`, 'g');
17
- const matchResults = [...oldFile.matchAll(regex)];
18
- let newFile = oldFile;
19
- matchResults.forEach((matchResult) => {
20
- const oldPath = matchResult[1];
21
- const remainingPath = matchResult[2];
22
- const before = join('addon', remainingPath);
23
- if (!mapping.has(before)) {
24
- return;
25
- }
26
- const after = mapping.get(before).replace(new RegExp('^addon/'), '');
27
- const newPath = join(projectName, after);
28
- newFile = newFile.replace(oldPath, newPath);
29
- });
30
- return newFile;
31
- }
32
- function updatePathsToTestFiles(oldFile, { mapping, projectName }) {
33
- const regex = new RegExp(`(?:'|")(${projectName}/(.*))(?:'|")`, 'g');
34
- const matchResults = [...oldFile.matchAll(regex)];
35
- let newFile = oldFile;
36
- matchResults.forEach((matchResult) => {
37
- const oldPath = matchResult[1];
38
- const remainingPath = matchResult[2];
39
- const before = remainingPath;
40
- if (!mapping.has(before)) {
41
- return;
42
- }
43
- const after = mapping.get(before);
44
- const newPath = join(projectName, after);
45
- newFile = newFile.replace(oldPath, newPath);
46
- });
47
- return newFile;
48
- }
49
- function updatePaths(mapping, options) {
50
- const { projectName, projectRoot } = options;
51
- // File extensions had been specified, partly to encode assumptions
52
- // about Ember, and partly to avoid corrupting non-text files
53
- const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
54
- projectRoot,
55
- });
56
- filePaths.forEach((filePath) => {
57
- const oldPath = join(projectRoot, filePath);
58
- const oldFile = readFileSync(oldPath, 'utf8');
59
- let newFile = updatePathsToAddonFiles(oldFile, {
60
- mapping,
61
- projectName,
62
- });
63
- newFile = updatePathsToTestFiles(newFile, {
64
- mapping,
65
- projectName: 'dummy',
66
- });
67
- writeFileSync(oldPath, newFile, 'utf8');
68
- });
69
- }
70
- export function updateAbsolutePaths(migrationStrategy, options) {
71
- const mapping = createMapping(migrationStrategy);
72
- updatePaths(mapping, options);
73
- }
@@ -1,41 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, relative, resolve } from 'node:path';
3
- import { findFiles } from '@codemod-utils/files';
4
- function removeRelativePaths(oldFile, { filePath, projectName, projectRoot, }) {
5
- const regex = new RegExp(`(?:'|")(.{1,2}/(.*))(?:'|")`, 'g');
6
- const matchResults = [...oldFile.matchAll(regex)];
7
- let newFile = oldFile;
8
- matchResults.forEach((matchResult) => {
9
- const oldPath = matchResult[1];
10
- let newPath = relative(projectRoot, resolve(projectRoot, dirname(filePath), oldPath));
11
- if (newPath.startsWith('addon')) {
12
- newPath = join(projectName, newPath.replace(new RegExp('^addon/'), ''));
13
- }
14
- else if (newPath.startsWith('tests')) {
15
- newPath = join('dummy', newPath);
16
- }
17
- newFile = newFile.replace(oldPath, newPath);
18
- });
19
- return newFile;
20
- }
21
- function updatePaths(options) {
22
- const { projectName, projectRoot } = options;
23
- // File extensions had been specified, partly to encode assumptions
24
- // about Ember, and partly to avoid corrupting non-text files
25
- const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
26
- projectRoot,
27
- });
28
- filePaths.forEach((filePath) => {
29
- const oldPath = join(projectRoot, filePath);
30
- const oldFile = readFileSync(oldPath, 'utf8');
31
- const newFile = removeRelativePaths(oldFile, {
32
- filePath,
33
- projectName,
34
- projectRoot,
35
- });
36
- writeFileSync(oldPath, newFile, 'utf8');
37
- });
38
- }
39
- export function useAbsolutePaths(options) {
40
- updatePaths(options);
41
- }
@@ -1,85 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, relative } from 'node:path';
3
- import { findFiles } from '@codemod-utils/files';
4
- function normalizeRelativePath(relativePath) {
5
- if (relativePath.startsWith('..')) {
6
- return relativePath;
7
- }
8
- return `./${relativePath}`;
9
- }
10
- function updateFile(oldFile, { filePath, projectName, projectRoot, }) {
11
- const regex = new RegExp(`(?:'|")(${projectName}/(.*/)*(.*))(?:'|")`, 'g');
12
- const matchResults = [...oldFile.matchAll(regex)];
13
- let newFile = oldFile;
14
- matchResults.forEach((matchResult) => {
15
- const oldPath = matchResult[1];
16
- const remainingDirectories = matchResult[2];
17
- const fileName = matchResult[3];
18
- const from = dirname(filePath);
19
- const to = join(projectRoot, remainingDirectories);
20
- const relativePath = join(relative(from, to), fileName);
21
- const newPath = normalizeRelativePath(relativePath);
22
- newFile = newFile.replace(oldPath, newPath);
23
- });
24
- return newFile;
25
- }
26
- function useRelativePathInAddonFolder(options) {
27
- const { projectName, projectRoot } = options;
28
- // File extensions had been specified, partly to encode assumptions
29
- // about Ember, and partly to avoid corrupting non-text files
30
- const filePaths = findFiles('addon/**/*.{d.ts,js,ts}', {
31
- projectRoot,
32
- });
33
- filePaths.forEach((filePath) => {
34
- const oldPath = join(projectRoot, filePath);
35
- const oldFile = readFileSync(oldPath, 'utf8');
36
- const newFile = updateFile(oldFile, {
37
- filePath,
38
- projectName,
39
- projectRoot: 'addon',
40
- });
41
- writeFileSync(oldPath, newFile, 'utf8');
42
- });
43
- }
44
- function useRelativePathInTestsFolder(options) {
45
- const { projectRoot } = options;
46
- // File extensions had been specified, partly to encode assumptions
47
- // about Ember, and partly to avoid corrupting non-text files
48
- const filePaths = findFiles('tests/**/*.{d.ts,js,ts}', {
49
- projectRoot,
50
- ignoreList: ['tests/dummy/**/*'],
51
- });
52
- filePaths.forEach((filePath) => {
53
- const oldPath = join(projectRoot, filePath);
54
- const oldFile = readFileSync(oldPath, 'utf8');
55
- const newFile = updateFile(oldFile, {
56
- filePath,
57
- projectName: 'dummy',
58
- projectRoot: '',
59
- });
60
- writeFileSync(oldPath, newFile, 'utf8');
61
- });
62
- }
63
- function useRelativePathInTestsDummyFolder(options) {
64
- const { projectRoot } = options;
65
- // File extensions had been specified, partly to encode assumptions
66
- // about Ember, and partly to avoid corrupting non-text files
67
- const filePaths = findFiles('tests/dummy/**/*.{d.ts,js,ts}', {
68
- projectRoot,
69
- });
70
- filePaths.forEach((filePath) => {
71
- const oldPath = join(projectRoot, filePath);
72
- const oldFile = readFileSync(oldPath, 'utf8');
73
- const newFile = updateFile(oldFile, {
74
- filePath,
75
- projectName: 'dummy',
76
- projectRoot: 'tests/dummy/app',
77
- });
78
- writeFileSync(oldPath, newFile, 'utf8');
79
- });
80
- }
81
- export function useRelativePaths(options) {
82
- useRelativePathInAddonFolder(options);
83
- useRelativePathInTestsFolder(options);
84
- useRelativePathInTestsDummyFolder(options);
85
- }