From dd6a96bebe76550f52e6d22dbafff9892f381b5a Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez <10727467+agonper@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:41:56 +0200 Subject: [PATCH 1/4] chore: bump TS v4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a09dc0c..51cf226 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "jasmine": "^3.5.0", "jasmine-spec-reporter": "^5.0.2", "tslint": "~6.1.0", - "typescript": "~4.0.0" + "typescript": "~4.1.0" }, "repository": { "type": "git", From ce3024dfb24351ae1638300d08ea4eb8a9640c67 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez <10727467+agonper@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:43:08 +0200 Subject: [PATCH 2/4] fix: properly parsing project object --- src/angular-project-parser.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/angular-project-parser.ts b/src/angular-project-parser.ts index eb7793d..411711d 100644 --- a/src/angular-project-parser.ts +++ b/src/angular-project-parser.ts @@ -1,14 +1,11 @@ import * as ts from 'typescript'; import { basename } from 'path'; -import { Tree, SchematicsException } from '@angular-devkit/schematics'; -import { - findBootstrapModuleCall, - findBootstrapModulePath, -} from '@schematics/angular/utility/ng-ast-utils'; +import { SchematicsException, Tree } from '@angular-devkit/schematics'; +import { findBootstrapModuleCall, findBootstrapModulePath } from '@schematics/angular/utility/ng-ast-utils'; import { getWorkspace } from '@schematics/angular/utility/workspace'; import { safeGet } from './utils'; -import { findNode, findImportPath, getSourceFile } from './ts-utils'; +import { findImportPath, findNode, getSourceFile } from './ts-utils'; export interface AngularProjectSettings { /** default: '' */ @@ -128,7 +125,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise< ); } - const buildTarget = targets.build; + const buildTarget = targets.get('build'); if (!buildTarget) { throw new SchematicsException( `Failed to find build target for project ${projectName}!`, @@ -139,7 +136,7 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise< const sourceRoot = project.sourceRoot || 'src'; const mainPath = safeGet(buildTarget, 'options', 'main'); const mainName = mainPath && basename(mainPath).replace(/\.ts$/, ''); - const prefix = project.prefix; + const prefix = project.prefix as string; const tsConfig = safeGet(buildTarget, 'options', 'tsConfig'); return { @@ -154,21 +151,20 @@ async function getCoreProjectSettings(tree: Tree, projectName: string): Promise< export async function getTsConfigFromProject(tree: Tree, projectName: string) { const { targets } = await parseAngularConfig(tree, projectName); - const tsConfig = safeGet(targets, 'build', 'options', 'tsConfig'); - return tsConfig; + return safeGet(targets, 'build', 'options', 'tsConfig'); } async function parseAngularConfig(tree, projectName: string) { const project = await getProjectObject(tree, projectName); - const targets = project.architect; + const targets = project.targets; return { targets, project }; } export async function getProjectObject(tree: Tree, projectName: string) { const workspace = await getWorkspace(tree); - const project = workspace.projects[projectName]; + const project = workspace.projects.get(projectName); if (!project) { throw new SchematicsException(`Couldn't find project "${projectName}" in the workspace!`); } From f86c54707490dd2aedd7cf84602770a46b823063 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez <10727467+agonper@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:43:51 +0200 Subject: [PATCH 3/4] fix: read style sheet extension from project object --- src/generate/component/index.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/generate/component/index.ts b/src/generate/component/index.ts index 3c04b04..b581629 100644 --- a/src/generate/component/index.ts +++ b/src/generate/component/index.ts @@ -45,25 +45,29 @@ let extensions: Extensions; export default function(options: ComponentOptions): Rule { let platformUse: PlatformUse; let componentInfo: ComponentInfo; + return chain([ - (tree: Tree) => { - platformUse = getPlatformUse(tree, options); + async (tree: Tree) => { + const projectObject = await getProjectObject(tree, options.project); - if (platformUse.nsOnly && options.spec !== true) { - options.spec = false; - } + return () => { + platformUse = getPlatformUse(tree, options); - const projectObject: any = getProjectObject(tree, options.project); - const style = (projectObject && projectObject.schematics && projectObject.schematics['@schematics/angular:component'] - && projectObject.schematics['@schematics/angular:component'].style); - if (style) { - options.style = style; - } + if (platformUse.nsOnly && options.spec !== true) { + options.spec = false; + } - validateGenerateOptions(platformUse, options); - validateGenerateComponentOptions(platformUse, options); + const style = (projectObject && projectObject.extensions.schematics && projectObject.extensions.schematics['@schematics/angular:component'] + && projectObject.extensions.schematics['@schematics/angular:component'].style); + if (style) { + options.style = style; + } - return tree; + validateGenerateOptions(platformUse, options); + validateGenerateComponentOptions(platformUse, options); + + return tree; + } }, () => externalSchematic( From 85d9aa9eec7159d6bc274224ae895ee90f671c23 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez <10727467+agonper@users.noreply.github.com> Date: Thu, 22 Apr 2021 15:44:41 +0200 Subject: [PATCH 4/4] docs: update README instruction default scss extension --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a92543f..78ecbf4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,12 @@ You need to add an `angular.json` configuration file to your NativeScript projec "root": "", "sourceRoot": ".", "projectType": "application", - "prefix": "app" + "prefix": "app", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + } } }, "defaultProject": "project-name"