Skip to content

Commit

Permalink
Ref changed folder structure and lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Iovino committed Jan 10, 2024
1 parent f2a8edb commit 3da640f
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 106 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/npmpub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
- uses: actions/checkout@v2

- run: npm install
- run: npm run pack
- run: cp README.md ./src/lib/dist/README.md
- run: cp README.md ./dist/README.md
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
Expand Down
79 changes: 57 additions & 22 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
"projects": {
"dev": {
"projectType": "application",
"schematics": {},
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"prefix": "app"
},
"@schematics/angular:directive": {
"prefix": "app"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
Expand All @@ -20,7 +28,6 @@
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
Expand All @@ -38,27 +45,27 @@
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
Expand All @@ -68,15 +75,12 @@
"configurations": {
"production": {
"buildTarget": "dev:build:production"
},
"development": {
"buildTarget": "dev:build:development"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "dev:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
Expand All @@ -91,14 +95,45 @@
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
}
},
"lib": {
"projectType": "library",
"root": "projects/lib",
"sourceRoot": "projects/lib/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/lib/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/lib/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "projects/lib/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "projects/lib/tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
}
}
}
}
},
"cli": {
"analytics": false
}
}
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"test": "node node_modules/@angular/cli/bin/ng test",
"test:headless": "node node_modules/@angular/cli/bin/ng test --browsers=ChromeHeadless",
"test:headless:singleRun": "node node_modules/@angular/cli/bin/ng test --no-watch --no-progress --browsers=ChromeHeadless",
"release:minor": "cd ./src/lib/ && npm version minor",
"release:major": "cd ./src/lib/ && npm version major",
"release:patch": "cd ./src/lib/ && npm version patch",
"pack": "ng-packagr -p ./src/lib/package.json"
"release:minor": "npm version minor && npm run build lib",
"release:major": "npm version major && npm run build lib",
"release:patch": "npm version patch && npm run build lib"
},
"private": true,
"dependencies": {
Expand All @@ -28,8 +27,8 @@
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.9",
"@angular/cli": "^17.0.9",
"@angular-devkit/build-angular": "^17.0.8",
"@angular/cli": "^17.0.8",
"@angular/compiler-cli": "^17.0.8",
"@types/jasmine": "~5.1.0",
"@types/jasminewd2": "~2.0.3",
Expand All @@ -40,7 +39,7 @@
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^17.0.3",
"ng-packagr": "^17.0.0",
"typescript": "5.2.2"
}
}
24 changes: 24 additions & 0 deletions projects/lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Lib

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.0.

## Code scaffolding

Run `ng generate component component-name --project lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project lib`.
> Note: Don't forget to add `--project lib` or else it will be added to the default project in your `angular.json` file.
## Build

Run `ng build lib` to build the project. The build artifacts will be stored in the `dist/` directory.

## Publishing

After building your library with `ng build lib`, go to the dist folder `cd dist/lib` and run `npm publish`.

## Running unit tests

Run `ng test lib` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
7 changes: 7 additions & 0 deletions projects/lib/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/lib",
"lib": {
"entryFile": "src/public-api.ts"
}
}
15 changes: 9 additions & 6 deletions src/lib/package.json → projects/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
],
"author": "Lorenzo Iovino",
"license": "MIT",
"ngPackage": {
"lib": {
"entryFile": "./ng2-fittext.module.ts"
}
"peerDependencies": {
"@angular/common": "^17.0.0",
"@angular/core": "^17.0.0"
},
"dependencies": {
"tslib": "^2.3.0"
},
"repository": {
"url": "https://github.com/thisloke/ng2-fittext.git"
}
}
},
"sideEffects": false
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Ng2FittextDirective } from '../ng2-fittext.directive';
import { Ng2FittextDirective } from '../../ng2-fittext.directive';
import { Renderer2, ElementRef } from '@angular/core';

describe('Class: Ng2FittextDirective', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Ng2FittextDirective } from './directives/ng2-fittext.directive';
import { Ng2FittextDirective } from './ng2-fittext.directive';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

export { Ng2FittextDirective } from './directives/ng2-fittext.directive';
export { Ng2FittextDirective } from './ng2-fittext.directive';

@NgModule({
declarations: [Ng2FittextDirective],
Expand All @@ -16,4 +16,4 @@ export class Ng2FittextModule {
providers: [],
};
}
}
}
6 changes: 6 additions & 0 deletions projects/lib/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Public API Surface of lib
*/

export * from './ng2-fittext.directive';
export * from './ng2-fittext.module';
14 changes: 14 additions & 0 deletions projects/lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": [
"**/*.spec.ts"
]
}
10 changes: 10 additions & 0 deletions projects/lib/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}
14 changes: 14 additions & 0 deletions projects/lib/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {Ng2FittextModule} from '../lib/ng2-fittext.module';
import { Ng2FittextModule } from 'lib';

@NgModule({
declarations: [
Expand Down
6 changes: 0 additions & 6 deletions src/lib/.gitignore

This file was deleted.

23 changes: 0 additions & 23 deletions src/lib/.npmignore

This file was deleted.

35 changes: 0 additions & 35 deletions src/lib/tsconfig.json

This file was deleted.

5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"paths": {
"lib": [
"./dist/lib"
]
},
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 3da640f

Please sign in to comment.