Skip to content

Commit

Permalink
Merge branch 'master' into landingpage-#1338-reflect-elements-version…
Browse files Browse the repository at this point in the history
…-to-url
  • Loading branch information
TobiasHeimGalindo committed Apr 24, 2024
2 parents 5c87ddd + 00ddf90 commit 074c5cc
Show file tree
Hide file tree
Showing 320 changed files with 2,136 additions and 5,115 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# http://editorconfig.org

# This config is automatically used by prettier
root = true

[*]
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/deploy-unicorn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:

- name: Save commit SHA to cache
id: current-commit
run:
echo "${{ github.event.pull_request.head.sha || github.sha }}" > last_commit_sha.txt
run: echo "${{ github.event.pull_request.head.sha || github.sha }}" > last_commit_sha.txt
&& echo "sha=${{ github.event.pull_request.base.sha || github.sha }}" >> $GITHUB_OUTPUT

- name: Get changed files
Expand Down
5 changes: 1 addition & 4 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"!(*eslintrc)!{packages/landingpage/**}.{t,j}s{,x}": [
"prettier --write",
"eslint --fix"
],
"!(*eslintrc)!{packages/landingpage/**}.{t,j}s{,x}": ["prettier --write", "eslint --fix"],
"*.{md,html,css,scss}": "prettier --write",
"*.{svg}": "svgo --config ./svgo.config.js"
}
8 changes: 4 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"singleQuote": true,
"jsxSingleQuote": false,
"printWidth": 80,
"printWidth": 120,
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always"
"arrowParens": "avoid",
"quoteProps": "as-needed",
"singleAttributePerLine": false
}
8 changes: 3 additions & 5 deletions commit-scope-enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ const packagesPath = path.join(__dirname, 'packages');
const packages = fs.readdirSync(packagesPath);

const componentsPath = path.join(packagesPath, 'elements', 'src', 'components');
const components = fs
.readdirSync(componentsPath)
.filter((p) => p.startsWith('ino-'));
const components = fs.readdirSync(componentsPath).filter(p => p.startsWith('ino-'));

const packageComponentList = packages
.filter((pkg) => pkg.match(/storybook$|elements(-[a-z]*)?$/))
.map((pkg) => components.map((cmp) => `${pkg}${separator}${cmp}`))
.filter(pkg => pkg.match(/storybook$|elements(-[a-z]*)?$/))
.map(pkg => components.map(cmp => `${pkg}${separator}${cmp}`))
.flat();

const commitScopes = [...packages, ...packageComponentList, "'*'", 'deps'];
Expand Down
17 changes: 3 additions & 14 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
},
"lint": {
"cache": true,
"inputs": [
"default",
"^production",
"{projectRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintrc.json"
],
"inputs": ["default", "^production", "{projectRoot}/.eslintrc.json", "{workspaceRoot}/.eslintrc.json"],
"defaultConfiguration": "check",
"configurations": {
"check": {
Expand All @@ -43,10 +38,7 @@
"options": {
"cwd": "{projectRoot}",
"parallel": false,
"commands": [
"nx run {projectName}:clean:dist",
"nx run {projectName}:clean:node"
]
"commands": ["nx run {projectName}:clean:dist", "nx run {projectName}:clean:node"]
},
"configurations": {
"dist": {
Expand Down Expand Up @@ -122,10 +114,7 @@
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": [
"{workspaceRoot}/tsconfig.json",
"{workspaceRoot}/tsconfig.base.json"
],
"sharedGlobals": ["{workspaceRoot}/tsconfig.json", "{workspaceRoot}/tsconfig.base.json"],
"production": [
"default",
"!{projectRoot}/**/*.e2e.ts",
Expand Down
5 changes: 1 addition & 4 deletions packages/elements-angular-example/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
}
]
},
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
]
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"]
},
{
"files": ["*.html"],
Expand Down
5 changes: 1 addition & 4 deletions packages/elements-angular-example/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/elements-angular-example/**/*.ts",
"packages/elements-angular-example/**/*.html"
]
"lintFilePatterns": ["packages/elements-angular-example/**/*.ts", "packages/elements-angular-example/**/*.html"]
}
},
"clean": {}
Expand Down
32 changes: 5 additions & 27 deletions packages/elements-angular-example/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,15 @@ <h1>Simple ToDo</h1>

<form class="app-wrapper" [formGroup]="form">
<div class="action-box">
<ino-input
formControlName="todoName"
type="text"
placeholder="What needs to be done..."
(keyup.enter)="add()"
>
<ino-icon
clickable="true"
(clickEl)="add()"
slot="icon-trailing"
icon="add"
></ino-icon>
<ino-input formControlName="todoName" type="text" placeholder="What needs to be done..." (keyup.enter)="add()">
<ino-icon clickable="true" (clickEl)="add()" slot="icon-trailing" icon="add"></ino-icon>
</ino-input>
</div>

<ino-list>
<ino-list-item
*ngFor="let todo of todos; index as i"
[text]="todo.name"
>
<ino-list-item *ngFor="let todo of todos; index as i" [text]="todo.name">
<ino-checkbox slot="leading" (click)="delete(todo)"></ino-checkbox>
<ino-button
variant="outlined"
dense="true"
slot="trailing"
(click)="delete(todo)"
>Delete</ino-button
>
<ino-button variant="outlined" dense="true" slot="trailing" (click)="delete(todo)">Delete</ino-button>
</ino-list-item>
</ino-list>

Expand All @@ -89,10 +70,7 @@ <h1>Simple ToDo</h1>

<div class="btn-box">
<ino-button (click)="toggleInputState()"
>{{
this.form.controls['todoName'].disabled ? 'Enable' : 'Disable'
}}
Input</ino-button
>{{ this.form.controls['todoName'].disabled ? 'Enable' : 'Disable' }} Input</ino-button
>
</div>
</main>
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-angular-example/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AppComponent {
}

delete(todo: Todo) {
this.todos = this.todos.filter((currentTodo) => currentTodo !== todo);
this.todos = this.todos.filter(currentTodo => currentTodo !== todo);
}

onViewModeChange(evt: Event): void {
Expand Down
7 changes: 1 addition & 6 deletions packages/elements-angular-example/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import { SharedModule } from './shared/shared.module';

@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
ReactiveFormsModule,
SharedModule,
InoElementsModule.forRoot(),
],
imports: [BrowserModule, ReactiveFormsModule, SharedModule, InoElementsModule.forRoot()],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-angular-example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { AppModule } from './app/app.module';

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch((err) => console.error(err));
.catch(err => console.error(err));
5 changes: 1 addition & 4 deletions packages/elements-angular/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": "off",
"@typescript-eslint/no-explicit-any": "warn",
Expand Down
9 changes: 3 additions & 6 deletions packages/elements-angular/buildHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ const path = require('path');

const args = process.argv;
const packageJsonPath = path.join(__dirname, 'package.json');
const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }),
);
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));

if (args[2] === 'preBuild') {
delete packageJson['exports'];
} else if (args[2] === 'postBuild') {
const extensions = ['.mjs', '.d.ts'];
const walk = (obj) => {
const walk = obj => {
for (const key in obj) {
if (typeof obj[key] === 'object') {
walk(obj[key]);
} else {
const value = obj[key].toString();
if (extensions.some((ext) => value.endsWith(ext)))
obj[key] = './' + path.posix.join('dist', value);
if (extensions.some(ext => value.endsWith(ext))) obj[key] = './' + path.posix.join('dist', value);
}
}
};
Expand Down
5 changes: 1 addition & 4 deletions packages/elements-angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/elements-angular/src/**/*.ts",
"packages/elements-angular/src/**/*.html"
]
"lintFilePatterns": ["packages/elements-angular/src/**/*.ts", "packages/elements-angular/src/**/*.html"]
}
},
"clean": {}
Expand Down
19 changes: 4 additions & 15 deletions packages/elements-angular/src/app-initialize.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import { NgZone, InjectionToken } from '@angular/core';
import {
applyPolyfills,
defineCustomElements,
} from '@inovex.de/elements/dist/loader';
import { applyPolyfills, defineCustomElements } from '@inovex.de/elements/dist/loader';
import { raf } from './utils';
import { InoElementsWindow, InoElementsConfig } from '@inovex.de/elements';

let didInitialize = false;

export const ConfigToken = new InjectionToken<InoElementsConfig>(
'INOVEX_ELEMENTS_CONFIG',
);
export const ConfigToken = new InjectionToken<InoElementsConfig>('INOVEX_ELEMENTS_CONFIG');

export const appInitialize = (
config: InoElementsConfig,
doc: Document,
zone: NgZone,
) => {
export const appInitialize = (config: InoElementsConfig, doc: Document, zone: NgZone) => {
return (): any => {
const win: InoElementsWindow | undefined = doc.defaultView as any;
if (win && typeof (window as any) !== 'undefined') {
Expand All @@ -29,9 +20,7 @@ export const appInitialize = (
win.inoElements.config = config;

const aelFn =
'__zone_symbol__addEventListener' in (doc.body as any)
? '__zone_symbol__addEventListener'
: 'addEventListener';
'__zone_symbol__addEventListener' in (doc.body as any) ? '__zone_symbol__addEventListener' : 'addEventListener';

return applyPolyfills().then(() => {
return defineCustomElements(win, {
Expand Down
11 changes: 2 additions & 9 deletions packages/elements-angular/src/ino-elements.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
APP_INITIALIZER,
ModuleWithProviders,
NgModule,
NgZone,
} from '@angular/core';
import { APP_INITIALIZER, ModuleWithProviders, NgModule, NgZone } from '@angular/core';
import { CommonModule, DOCUMENT } from '@angular/common';
import { InoElementsConfig } from '@inovex.de/elements';
import { DIRECTIVES } from './directives/proxies-list';
Expand Down Expand Up @@ -37,9 +32,7 @@ const DECLARATIONS = [
exports: DECLARATIONS,
})
export class InoElementsModule {
static forRoot(
config?: InoElementsConfig,
): ModuleWithProviders<InoElementsModule> {
static forRoot(config?: InoElementsConfig): ModuleWithProviders<InoElementsModule> {
return {
ngModule: InoElementsModule,
providers: [
Expand Down
25 changes: 4 additions & 21 deletions packages/elements-angular/src/schematics/add/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import { Path, join } from '@angular-devkit/core';
import {
chain,
Rule,
SchematicContext,
SchematicsException,
Tree,
} from '@angular-devkit/schematics';
import { chain, Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { addPackageToPackageJson } from '../utils/package';
import { addElementsModuleImportToNgModule } from '../utils/ast';
import {
addAsset,
getDefaultAngularAppName,
getWorkspace,
} from '../utils/config';
import { addAsset, getDefaultAngularAppName, getWorkspace } from '../utils/config';

import { Schema as Options } from './schema';

function addElementsAngularToDependencies(): Rule {
return (host: Tree) => {
addPackageToPackageJson(
host,
'dependencies',
'@inovex.de/elements-angular',
'latest',
);
addPackageToPackageJson(host, 'dependencies', '@inovex.de/elements-angular', 'latest');
return host;
};
}
Expand Down Expand Up @@ -83,9 +68,7 @@ export default function ngAdd(options: Options): Rule {
const project = workspace.projects[options.project];

if (!project || project['projectType'] !== 'application') {
throw new SchematicsException(
`Elements add does not support project types other than "application".`,
);
throw new SchematicsException(`Elements add does not support project types other than "application".`);
}

const sourcePath: Path = join(project.sourceRoot as Path);
Expand Down
17 changes: 3 additions & 14 deletions packages/elements-angular/src/schematics/utils/ast.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { Tree } from '@angular-devkit/schematics';
import { SchematicsException } from '@angular-devkit/schematics';
import {
addSymbolToNgModuleMetadata,
insertImport,
} from '@schematics/angular/utility/ast-utils';
import { addSymbolToNgModuleMetadata, insertImport } from '@schematics/angular/utility/ast-utils';
import { applyToUpdateRecorder } from '@schematics/angular/utility/change';
import * as ts from 'typescript';

Expand All @@ -16,22 +13,14 @@ function getSourceFile(host: Tree, path: string): ts.SourceFile {
throw new SchematicsException(`Could not find file for path: ${path}`);
}
const content = buffer.toString();
const source = ts.createSourceFile(
path,
content,
ts.ScriptTarget.Latest,
true,
);
const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
return source;
}

/**
* Import and add module to root app module.
*/
export function addElementsModuleImportToNgModule(
host: Tree,
modulePath: string,
): void {
export function addElementsModuleImportToNgModule(host: Tree, modulePath: string): void {
const recorder = host.beginUpdate(modulePath);
const moduleSource = getSourceFile(host, modulePath) as any;

Expand Down
Loading

0 comments on commit 074c5cc

Please sign in to comment.