Skip to content

Commit

Permalink
fix devkit
Browse files Browse the repository at this point in the history
  • Loading branch information
hirsch88 committed Feb 29, 2024
1 parent 1da0a64 commit 06901dd
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
BalConfigState,
BalLanguage,
onBalConfigChange,
} from '@baloise/design-system-components';
import { BalConfigService } from '@baloise/design-system-components-angular/standalone';
} from '@baloise/ds-core';
import { BalConfigService } from '@baloise/ds-angular';
import { TranslocoService } from '@ngneat/transloco';

export function initializeI18n(
Expand Down
12 changes: 6 additions & 6 deletions packages/devkit/src/ng-add/generators/app.get.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { SchematicsException, Tree } from '@angular-devkit/schematics'
import { SchemaOptions } from '../schema'
import { getPrefix } from '../utils/workspace'

export const updateAppComponent = (host: Tree, options: SchemaOptions) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const updateAppComponent = (host: Tree) => {
const appTemplatePath = `src/app/app.component.html`
const appComponentPath = `src/app/app.component.ts`
const appStylesPath = `src/app/app.component.css`
const appStylesSassPath = `src/app/app.component.scss`

const isInlineTemplate = !host.exists(appTemplatePath)
const tempContent = host.readText(isInlineTemplate ? appComponentPath : appTemplatePath)
const prefix = tempContent.includes('app-root') ? 'app' : options.project
const prefix = getPrefix(host)

const hasCssStyles = host.exists(appStylesPath)
const hasSassStyles = host.exists(appStylesSassPath)
Expand All @@ -27,7 +27,7 @@ export const updateAppComponent = (host: Tree, options: SchemaOptions) => {
appComponentPath,
`import { Component, CUSTOM_ELEMENTS_SCHEMA${isOnPush ? ', ChangeDetectionStrategy' : ''} } from '@angular/core'
import { CommonModule } from '@angular/common'
import { BalLayoutBundle, BalHeading, BalButton } from '@baloise/design-system-components-angular/standalone'
import { BalLayoutBundle, BalHeading, BalButton } from '@baloise/ds-angular'
@Component({
selector: '${prefix}-root',
Expand Down Expand Up @@ -57,7 +57,7 @@ export class AppComponent {}
appComponentPath,
`import { Component, CUSTOM_ELEMENTS_SCHEMA${isOnPush ? ', ChangeDetectionStrategy' : ''} } from '@angular/core'
import { CommonModule } from '@angular/common'
import { BalLayoutBundle, BalHeading, BalButton } from '@baloise/design-system-components-angular/standalone'
import { BalLayoutBundle, BalHeading, BalButton } from '@baloise/ds-angular'
@Component({
selector: '${prefix}-root',
Expand Down
3 changes: 2 additions & 1 deletion packages/devkit/src/ng-add/generators/project.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export function updateProjectConfig(host: Tree) {
/**
* Angular Workspace
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const angularConfig = getAngularWorkspace(host) as any
const projectName = Object.keys(angularConfig.projects)[0]
angularConfig.projects[projectName].architect.build.options.polyfills = POLYFILLS
angularConfig.projects[projectName].architect.build.configurations.production.budgets.budgets = BUDGETS
angularConfig.projects[projectName].architect.build.configurations.production.budgets = BUDGETS
const newNxConfig = JSON.stringify(angularConfig, undefined, 2)
return host.overwrite('angular.json', newNxConfig)
}
Expand Down
30 changes: 15 additions & 15 deletions packages/devkit/src/ng-add/generators/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ export const addStyles = (host: Tree) => {
}
const content = configBuffer.toString()

if (!content.includes('@baloise/design-system-styles/css/core')) {
if (!content.includes('@baloise/ds-styles/css/core')) {
const newContent =
content +
`
// SASS mixins and SASS variables
@import '@baloise/design-system-styles/sass/mixins';
@import '@baloise/ds-styles/sass/mixins';
// Resets CSS for all browser
@import '@baloise/design-system-styles/css/normalize';
@import '@baloise/design-system-styles/css/structure';
@import '@baloise/ds-styles/css/normalize';
@import '@baloise/ds-styles/css/structure';
// Custom font faces
@import '@baloise/design-system-styles/css/font';
@import '@baloise/ds-styles/css/font';
// Core CSS with CSS variables, always required
@import '@baloise/design-system-styles/css/core';
@import '@baloise/ds-styles/css/core';
// CSS utilities classes (optional)
@import '@baloise/design-system-styles/css/utilities/background';
@import '@baloise/design-system-styles/css/utilities/border';
@import '@baloise/design-system-styles/css/utilities/elevation';
@import '@baloise/design-system-styles/css/utilities/flex';
@import '@baloise/design-system-styles/css/utilities/interaction';
@import '@baloise/design-system-styles/css/utilities/layout';
@import '@baloise/design-system-styles/css/utilities/sizing';
@import '@baloise/design-system-styles/css/utilities/spacing';
@import '@baloise/design-system-styles/css/utilities/typography';
@import '@baloise/ds-styles/css/utilities/background';
@import '@baloise/ds-styles/css/utilities/border';
@import '@baloise/ds-styles/css/utilities/elevation';
@import '@baloise/ds-styles/css/utilities/flex';
@import '@baloise/ds-styles/css/utilities/interaction';
@import '@baloise/ds-styles/css/utilities/layout';
@import '@baloise/ds-styles/css/utilities/sizing';
@import '@baloise/ds-styles/css/utilities/spacing';
@import '@baloise/ds-styles/css/utilities/typography';
`
host.overwrite(filePath, newContent)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/devkit/src/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function (options: SchemaOptions): Rule {
actions.push(
addRootProvider(options.project, ({ code, external }) => {
return code`
${external('provideBaloiseDesignSystem', '@baloise/design-system-components-angular/standalone')}({
${external('provideBaloiseDesignSystem', '@baloise/ds-angular')}({
defaults: {
region: '${options.region}',
}
Expand All @@ -43,7 +43,7 @@ export default function (options: SchemaOptions): Rule {
multi: true,
deps: [${external('TranslocoService', '@ngneat/transloco')}, ${external(
'BalConfigService',
'@baloise/design-system-components-angular/standalone',
'@baloise/ds-angular',
)}],
}`
}),
Expand All @@ -55,9 +55,9 @@ export default function (options: SchemaOptions): Rule {
host.delete(nxExample)
}

updateAppComponent(host, options)
updateAppComponent(host)

actions.push(addDependency('@baloise/design-system-components-angular', 'latest'))
actions.push(addDependency('@baloise/ds-angular', 'latest'))

return chain(actions)(host, context) as any
}
Expand Down
12 changes: 12 additions & 0 deletions packages/devkit/src/ng-add/utils/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ export function getWorkspace(host: Tree, path: string): WorkspaceSchema {

return JSON.parse(config)
}

export function getPrefix(host: Tree) {
if (isNxWorkspace(host)) {
const config = getNXWorkspace(host)
return config.prefix
} else {
const config = getAngularWorkspace(host)
const projektKeys = Object.keys(config.projects)
const mainProject = config.projects[projektKeys[0]]
return mainProject.prefix
}
}
10 changes: 1 addition & 9 deletions packages/devkit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"compilerOptions": {},
"files": [],
"include": [],
"references": [
Expand Down
18 changes: 17 additions & 1 deletion packages/devkit/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"outDir": "dist/out-tsc",
"baseUrl": ".",
"lib": ["es2018", "dom"],
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"rootDir": "src",
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"target": "es6",
"types": ["node"]
},
"include": ["src/**/*"],
Expand Down

0 comments on commit 06901dd

Please sign in to comment.