Skip to content

Commit 3140e94

Browse files
committed
chore(migrations): switch launch config to work from dist
1 parent aa4990a commit 3140e94

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

.vscode/launch.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,13 @@
2727
// "cwd": "<absolute directory of the project, having an old version of igniteui-angular, on which the migrations are applied>",
2828
"cwd": "C:\\Users\\User\\Desktop\\ng_proj\\test_migrations",
2929
"args": [
30-
"-r",
31-
32-
// you need to install ts-node for the test project
33-
"ts-node/register",
34-
3530
// "<path/to/ng>", "g",
3631
"${env:AppData}/npm/node_modules/@angular/cli/bin/ng", "g",
3732

38-
// "<../../relative/path/from/cwd/to>/igniteui-angular/projects/igniteui-angular/migrations/migration-collection.json:migration-<number>
39-
"../../../../../work/git/igniteui-angular/projects/igniteui-angular/migrations/migration-collection.json:migration-24"
33+
// "<../../relative/path/from/cwd/to>/igniteui-angular/dist/igniteui-angular/migrations/migration-collection.json:migration-<number>
34+
"../../../../../work/git/igniteui-angular/dist/igniteui-angular/migrations/migration-collection.json:migration-23"
4035
],
41-
"env": {
42-
"TS_NODE_PROJECT": "${workspaceFolder}/projects/igniteui-angular/migrations/tsconfig.json"
43-
}
36+
"preLaunchTask": "buildMigrations"
4437
},
4538
{
4639
"name": "Run schematics",

.vscode/tasks.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "build:schematics",
7+
"problemMatcher": [],
8+
"label": "buildSchematics",
9+
"detail": "Build schematics"
10+
},
11+
{
12+
"type": "npm",
13+
"script": "build:migrations -- --sourceMap",
14+
"dependsOn": [
15+
"buildSchematics"
16+
],
17+
"problemMatcher": [],
18+
"label": "buildMigrationsSourceMap",
19+
"detail": "Build migrations with sourceMap for debugging"
20+
},
21+
{
22+
"type": "shell",
23+
"command": "node ./scripts/migrations-sourcemap-shift.mjs",
24+
"dependsOn": [
25+
"buildMigrationsSourceMap"
26+
],
27+
"problemMatcher": [],
28+
"label": "buildMigrations",
29+
"detail": "Build migrations with sourceMap for debugging"
30+
},
31+
]
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { globby } from 'globby';
2+
import { readFileSync, writeFileSync } from 'fs';
3+
4+
/**
5+
* Small patch for debugging compiled migrations that get wrapped with extra lines for encapsulation:
6+
* https://github.com/angular/angular-cli/blob/e51b9068763a115fa27d06e2dd7988b34a3f677c/packages/angular/cli/src/command-builder/utilities/schematic-engine-host.ts#L213-L215
7+
* Works for the simple "version":3 mappings produced where adding ; at the start shifts the mapped lines (ignores the extra unmapped source)
8+
*/
9+
(async () => {
10+
const paths = await globby('dist/igniteui-angular/migrations/**/*.js.map');
11+
for (const path of paths) {
12+
const extraLine = ';';
13+
const offset = 3;
14+
let content = readFileSync(path, { encoding: 'utf-8' });
15+
content = content.replace(`"mappings":"`, `"mappings":"${extraLine.repeat(offset)}`);
16+
writeFileSync(path, content);
17+
}
18+
})();

0 commit comments

Comments
 (0)