Skip to content

Commit

Permalink
fix(@angular-devkit/core): handle number like strings in workspace wr…
Browse files Browse the repository at this point in the history
…iter

The workspace writer previously transformed number like strings to numbers which causes failures when a project is named using a number like name.

Closes #24541

(cherry picked from commit f6f5d79)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Jan 19, 2023
1 parent f31bf30 commit 9de9920
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-app": {
"root": "",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my-app:build"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "my-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"my-app-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "my-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "my-app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"1": {
"root": "src"
}
},
"defaultProject": "my-app"
}
4 changes: 1 addition & 3 deletions packages/angular_devkit/core/src/workspace/json/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,10 @@ function updateJsonWorkspace(metadata: JsonWorkspaceMetadata): string {
jsonPath[2] = 'architect';
}

// modify
const newJsonPath = jsonPath.map((v) => (isFinite(+v) ? +v : v));
// TODO: `modify` re-parses the content every time.
// See: https://github.com/microsoft/node-jsonc-parser/blob/35d94cd71bd48f9784453b2439262c938e21d49b/src/impl/edit.ts#L18
// Ideally this should accept a string or an AST to avoid the potentially expensive repeat parsing operation.
const edits = modify(content, newJsonPath, normalizeValue(value, type), {
const edits = modify(content, jsonPath, normalizeValue(value, type), {
formattingOptions: {
insertSpaces: true,
tabSize: 2,
Expand Down
Loading

0 comments on commit 9de9920

Please sign in to comment.