Skip to content

Commit 746c269

Browse files
authored
Documented the case of a scoped package (#17)
* chore: Added test fixtures * chore: Added tests * bugfix: Updated the regular expression for finding old paths * chore: Updated test fixtures * bugfix: Listed the locations of the addon and test-app in the workspaces field * chore: Updated test fixtures * chore: Standardized test setup (create-options) --------- Co-authored-by: ijlee2 <[email protected]>
1 parent fcbec28 commit 746c269

File tree

531 files changed

+40107
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

531 files changed

+40107
-153
lines changed

codemod-test-fixtures.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
./codemod-test-fixture.sh -a "packages/ember-container-query" -t "demo-app" -T "demo-app-for-ember-container-query" ember-container-query-customizations
1616
./codemod-test-fixture.sh ember-container-query-glint
1717
./codemod-test-fixture.sh ember-container-query-javascript
18+
./codemod-test-fixture.sh ember-container-query-scoped
1819
./codemod-test-fixture.sh ember-container-query-typescript
1920
./codemod-test-fixture.sh -a "packages/new-v1-addon" -t "demo-app" -T "demo-app-for-new-v1-addon" new-v1-addon-customizations
2021
./codemod-test-fixture.sh new-v1-addon-javascript

src/blueprints/ember-addon/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"license": "MIT",
77
"author": "",
88
"workspaces": [
9-
"<%= options.packages.addon.name %>",
10-
"<%= options.packages.testApp.name %>"
9+
"<%= options.locations.addon %>",
10+
"<%= options.locations.testApp %>"
1111
],
1212
"scripts": {
1313
"build": "npm run build --workspace <%= options.packages.addon.name %>",
@@ -31,8 +31,8 @@
3131
"license": "MIT",
3232
"author": "",
3333
"workspaces": [
34-
"<%= options.packages.addon.name %>",
35-
"<%= options.packages.testApp.name %>"
34+
"<%= options.locations.addon %>",
35+
"<%= options.locations.testApp %>"
3636
],
3737
"scripts": {
3838
"build": "pnpm --filter <%= options.packages.addon.name %> build",
@@ -56,8 +56,8 @@
5656
"license": "MIT",
5757
"author": "",
5858
"workspaces": [
59-
"<%= options.packages.addon.name %>",
60-
"<%= options.packages.testApp.name %>"
59+
"<%= options.locations.addon %>",
60+
"<%= options.locations.testApp %>"
6161
],
6262
"scripts": {
6363
"build": "yarn workspace <%= options.packages.addon.name %> run build",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
packages:
2-
- '<%= options.packages.addon.name %>'
3-
- '<%= options.packages.testApp.name %>'
2+
- '<%= options.locations.addon %>'
3+
- '<%= options.locations.testApp %>'

src/migration/ember-addon/steps/use-relative-paths.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ function normalizeRelativePath(relativePath) {
1212
}
1313

1414
function updateFile(oldFile, { filePath, projectName, projectRoot }) {
15-
const regex = new RegExp(`\\b${projectName}/(.*/)*(.*)\\b`, 'g');
15+
const regex = new RegExp(`(?:'|")(${projectName}/(.*/)*(.*))(?:'|")`, 'g');
1616
const matchResults = [...oldFile.matchAll(regex)];
1717

1818
let newFile = oldFile;
1919

2020
matchResults.forEach((matchResult) => {
21-
const [magicImportPath, remainingDirectories, fileName] = matchResult;
21+
// eslint-disable-next-line no-unused-vars
22+
const [_, oldPath, remainingDirectories, fileName] = matchResult;
2223

2324
const from = dirname(filePath);
2425
const to = join(projectRoot, remainingDirectories);
2526

2627
const relativePath = join(relative(from, to), fileName);
27-
const trueImportPath = normalizeRelativePath(relativePath);
28+
const newPath = normalizeRelativePath(relativePath);
2829

29-
newFile = newFile.replace(magicImportPath, trueImportPath);
30+
newFile = newFile.replace(oldPath, newPath);
3031
});
3132

3233
return newFile;

tests/fixtures/ember-container-query-customizations/output/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"license": "MIT",
77
"author": "",
88
"workspaces": [
9-
"ember-container-query",
10-
"demo-app-for-ember-container-query"
9+
"packages/ember-container-query",
10+
"demo-app"
1111
],
1212
"scripts": {
1313
"build": "yarn workspace ember-container-query run build",

tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/src/helpers/cq-aspect-ratio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deprecate(
1313
enabled: '3.2.0',
1414
},
1515
until: '4.0.0',
16-
url: 'https://github.com/ijlee2/../tree/3.2.0#api',
16+
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
1717
}
1818
);
1919

tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/src/helpers/cq-height.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deprecate(
1313
enabled: '3.2.0',
1414
},
1515
until: '4.0.0',
16-
url: 'https://github.com/ijlee2/../tree/3.2.0#api',
16+
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
1717
}
1818
);
1919

tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/src/helpers/cq-width.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deprecate(
1313
enabled: '3.2.0',
1414
},
1515
until: '4.0.0',
16-
url: 'https://github.com/ijlee2/../tree/3.2.0#api',
16+
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
1717
}
1818
);
1919

tests/fixtures/ember-container-query-glint/output/ember-container-query/src/helpers/cq-aspect-ratio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deprecate(
1313
enabled: '3.2.0',
1414
},
1515
until: '4.0.0',
16-
url: 'https://github.com/ijlee2/../tree/3.2.0#api',
16+
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
1717
}
1818
);
1919

tests/fixtures/ember-container-query-glint/output/ember-container-query/src/helpers/cq-height.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deprecate(
1313
enabled: '3.2.0',
1414
},
1515
until: '4.0.0',
16-
url: 'https://github.com/ijlee2/../tree/3.2.0#api',
16+
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
1717
}
1818
);
1919

0 commit comments

Comments
 (0)