Skip to content

Commit

Permalink
Generator Bugs and App config fixes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
alkrobinson authored Aug 21, 2024
1 parent e7f822d commit a6a09cd
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 215 deletions.
244 changes: 121 additions & 123 deletions apps/component-doc-portal/project.json
Original file line number Diff line number Diff line change
@@ -1,123 +1,121 @@
{
"name": "component-doc-portal",
"$schema": "..\\..\\node_modules\\nx\\schemas\\project-schema.json",
"projectType": "application",
"sourceRoot": "apps/component-doc-portal/src",
"prefix": "component-doc-portal",
"targets": {
"compile": {
"executor": "@oasisdigital/ng-doc-portal-plugin:compile",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
}
},
"build": {
"executor": "@oasisdigital/ng-doc-portal-plugin:build",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
},
"configurations": {
"production": {
"ngConfigTarget": "production"
},
"configuration": {
"ngConfigTarget": "development"
}
}
},
"serve": {
"executor": "@oasisdigital/ng-doc-portal-plugin:serve",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
},
"configurations": {
"production": {
"ngConfigTarget": "production"
},
"configuration": {
"ngConfigTarget": "development"
}
}
},
"extract-i18n": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx nx compile component-doc-portal",
"forwardAllArgs": false
},
{
"command": "npx nx ng-extract-i18n component-doc-portal"
}
],
"parallel": false
}
},
"ng-build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/component-doc-portal",
"index": "apps/component-doc-portal/src/index.html",
"main": "apps/component-doc-portal/src/main.ts",
"polyfills": "apps/component-doc-portal/src/polyfills.ts",
"tsConfig": "apps/component-doc-portal/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/component-doc-portal/src/favicon.ico",
"apps/component-doc-portal/src/assets"
],
"styles": [
"libs/ng-doc-portal/src/lib/styles/milligram.scss",
"libs/ng-doc-portal/src/lib/styles/ng-doc-portal.scss",
"apps/component-doc-portal/src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"ng-serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "component-doc-portal:ng-build:production"
},
"development": {
"buildTarget": "component-doc-portal:ng-build:development"
}
},
"defaultConfiguration": "development"
},
"ng-extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "component-doc-portal:ng-build"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/component-doc-portal"],
"options": {
"jestConfig": "apps/component-doc-portal/jest.config.ts"
}
}
},
"tags": []
}
{
"name": "component-doc-portal",
"$schema": "..\\..\\node_modules\\nx\\schemas\\project-schema.json",
"projectType": "application",
"sourceRoot": "apps/component-doc-portal/src",
"prefix": "component-doc-portal",
"targets": {
"compile": {
"executor": "@oasisdigital/ng-doc-portal-plugin:compile",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
}
},
"build": {
"executor": "@oasisdigital/ng-doc-portal-plugin:build",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
},
"configurations": {
"production": {
"ngConfigTarget": "production"
},
"configuration": {
"ngConfigTarget": "development"
}
}
},
"serve": {
"executor": "@oasisdigital/ng-doc-portal-plugin:serve",
"options": {
"configFile": "apps/component-doc-portal/ng-doc-portal-config.json"
},
"configurations": {
"production": {
"ngConfigTarget": "production"
},
"configuration": {
"ngConfigTarget": "development"
}
}
},
"extract-i18n": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx nx compile component-doc-portal",
"forwardAllArgs": false
},
{
"command": "npx nx ng-extract-i18n component-doc-portal"
}
],
"parallel": false
}
},
"ng-build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/component-doc-portal",
"index": "apps/component-doc-portal/src/index.html",
"browser": "apps/component-doc-portal/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/component-doc-portal/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/component-doc-portal/src/favicon.ico",
"apps/component-doc-portal/src/assets"
],
"styles": [
"libs/ng-doc-portal/src/lib/styles/milligram.scss",
"libs/ng-doc-portal/src/lib/styles/ng-doc-portal.scss",
"apps/component-doc-portal/src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"ng-serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "component-doc-portal:ng-build:production"
},
"development": {
"buildTarget": "component-doc-portal:ng-build:development"
}
},
"defaultConfiguration": "development"
},
"ng-extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "component-doc-portal:ng-build"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/component-doc-portal"],
"options": {
"jestConfig": "apps/component-doc-portal/jest.config.ts"
}
}
},
"tags": []
}
52 changes: 0 additions & 52 deletions apps/component-doc-portal/src/polyfills.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/component-doc-portal/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"target": "ES2022",
"useDefineForClassFields": false
},
"files": ["src/main.ts", "src/polyfills.ts"],
"files": ["src/main.ts"],
"include": ["src/**/*.d.ts"],
"exclude": [
"**/*.test.ts",
Expand Down
13 changes: 2 additions & 11 deletions libs/ng-doc-portal-plugin/src/executors/compiler/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export async function extractTitleFromDocPageFile(
) {
const title = await getTitleFromTypeScript(filePath);
const prefix = findTitlePrefixFromGlobPatterns(filePath, globPatterns);

if (prefix) {
return `${prefix}/${title}`;
} else {
Expand All @@ -226,20 +225,11 @@ export async function extractTitleFromDocPageFile(
export function generateDocPageLoader(filePath: string, title: string) {
// Figure out variables for config list file output
const filePathWithoutExtension = filePath.replace('.ts', '');
/* If nested folders are used */
const nestedPathCount = (
filePathWithoutExtension.split('/src')[0].split('apps/')[1].match(/\//g) ||
[]
).length;
const route = title.toLowerCase().replace(/[ /]/g, '-');
let startingPath = '../../../../';
for (let index = 0; index < nestedPathCount; index++) {
startingPath += '../';
}
return `
'${route}': {
title: '${title}',
fetch: () => import('${startingPath}${filePathWithoutExtension}').then((file) => file.default)
fetch: () => import('../../../../${filePathWithoutExtension}').then((file) => file.default)
}
`;
}
Expand All @@ -264,6 +254,7 @@ export async function formatContent(content: string): Promise<string> {
*/
export function wrapTypescriptBoilerplate(configStrings: string[]) {
return `
/* eslint-disable */
import { DocPageLoaderRecord } from '@oasisdigital/ng-doc-portal';
export const docPageLoaders: DocPageLoaderRecord = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { Component, NgModule } from '@angular/core';

import { DocPageConfig } from '@oasisdigital/ng-doc-portal';

@Component({
template: `
<h1>Starting template for <%= className %></h1>
<label>Example Label</label>
`,
})
export class <%= className %>DocumentPageComponent {}

// This can probably go away when Optional Modules is in Angular
@NgModule({
declarations: [],
imports: [],
providers: [],
})
export class DocumentPageModule {}

const docPageConfig: DocPageConfig = {
title: '<%= path %><%= className %>',
docPageComponent: <%= className %>DocumentPageComponent,
ngModule: DocumentPageModule,
};

export default docPageConfig;
import { Component, NgModule } from '@angular/core';

import { DocPageConfig } from '@oasisdigital/ng-doc-portal';

@Component({
standalone:true,
template: `
<h1>Starting template for <%= className %></h1>
<label>Example Label</label>
`,
})
export class <%= className %>DocumentPageComponent {}

const docPageConfig: DocPageConfig = {
title: '<%= path %><%= className %>',
component: <%= className %>DocumentPageComponent
};

export default docPageConfig;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~highlight.js/styles/github.css';
@import 'highlight.js/styles/github.css';

ngdp-code-snippet {
div.hljs {
Expand Down

0 comments on commit a6a09cd

Please sign in to comment.