Add version update. Create packaging script

This commit is contained in:
Konstantinos Triantafyllou 2023-09-14 11:48:22 +03:00
parent ecce8a679f
commit 7e0e641e5f
17 changed files with 13184 additions and 2 deletions

View File

@ -3,5 +3,38 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"version-update": {
"projectType": "library",
"root": "projects/version-update",
"sourceRoot": "projects/version-update/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/version-update/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/version-update/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "projects/version-update/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "projects/version-update/tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
}
}
}
}
}
}

12905
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,9 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"test": "ng test",
"build-lib": "ng-packagr -p projects/$npm_config_lib/ng-package.json",
"package": "tsc package.ts && node package.ts"
},
"private": true,
"dependencies": {
@ -23,6 +25,7 @@
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.2.1",
"@angular/cli": "~16.2.0",
"@angular/compiler-cli": "^16.2.0",
"@types/jasmine": "~4.3.0",
@ -32,6 +35,7 @@
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^16.2.0",
"typescript": "~5.1.3"
}
}

70
package.ts Normal file
View File

@ -0,0 +1,70 @@
import * as process from "process";
import {error} from "ng-packagr/lib/utils/log";
const { exec } = require('child_process');
type Dependency = 'version-update';
/** Add the dependencies you want to add to your projects */
let dependencies: Dependency[] = ['version-update'];
const repository: string = 'openaire-libraries';
const gitURL: string = `https://code-repo.d4science.org/MaDgIK/${repository}.git`;
console.log('Cloning ' + repository);
function installDependency(index: number) {
if(index < dependencies.length) {
exec(`npm run build-lib --lib=${dependencies[index]}`, (error:string) => {
if(error) {
console.error(`Error packaging ${dependencies[index]}: ${error}`);
clean();
return;
}
process.chdir('../');
exec(`npm install --no-save ./${repository}/projects/${dependencies[index]}`, (installError: string) => {
if(error) {
console.error(`Error installing ${dependencies[index]}: ${installError}`);
clean();
return;
}
process.chdir(repository);
installDependency(index + 1);
});
});
} else {
clean();
}
}
function clean() {
/** Clean files after packaging */
console.log('Cleaning files')
process.chdir('../')
exec(`rm -rf ${repository} package.js`, (error: string) => {
if(error) {
console.error(`Error cleaning files: ${error}`);
return;
}
});
}
/**
* Clone ${repository}
* */
exec(`git clone ${gitURL}`, (cloneError: string) => {
if(cloneError) {
console.error(`Error cloning the ${repository}: ${cloneError}`);
return;
}
console.log(`${repository} cloned successfully.`);
process.chdir(repository);
/** Installing node modules */
exec(`npm install`, (npmError: string) => {
if(npmError) {
console.error(`Error installing node modules: ${npmError}`);
return;
}
installDependency(0);
});
})

View File

@ -0,0 +1,24 @@
# VersionUpdate
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
## Code scaffolding
Run `ng generate component component-name --project version-update` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project version-update`.
> Note: Don't forget to add `--project version-update` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build version-update` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build version-update`, go to the dist folder `cd dist/version-update` and run `npm publish`.
## Running unit tests
Run `ng test version-update` 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.

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/version-update",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,12 @@
{
"name": "version-update",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^16.2.0",
"@angular/core": "^16.2.0"
},
"dependencies": {
"tslib": "^2.3.0"
},
"sideEffects": false
}

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { VersionUpdateComponent } from './version-update.component';
describe('VersionUpdateComponent', () => {
let component: VersionUpdateComponent;
let fixture: ComponentFixture<VersionUpdateComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [VersionUpdateComponent]
});
fixture = TestBed.createComponent(VersionUpdateComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component } from '@angular/core';
@Component({
selector: 'lib-version-update',
template: `
<p>
version-update works!
</p>
`,
styles: [
]
})
export class VersionUpdateComponent {
}

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { VersionUpdateComponent } from './version-update.component';
@NgModule({
declarations: [
VersionUpdateComponent
],
imports: [
],
exports: [
VersionUpdateComponent
]
})
export class VersionUpdateModule { }

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { VersionUpdateService } from './version-update.service';
describe('VersionUpdateService', () => {
let service: VersionUpdateService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(VersionUpdateService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class VersionUpdateService {
constructor() { }
}

View File

@ -0,0 +1,7 @@
/*
* Public API Surface of version-update
*/
export * from './lib/version-update.service';
export * from './lib/version-update.component';
export * from './lib/version-update.module';

View File

@ -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"
]
}

View File

@ -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"
}
}

View File

@ -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"
]
}

View File

@ -22,7 +22,12 @@
"lib": [
"ES2022",
"dom"
]
],
"paths": {
"version-update": [
"dist/version-update"
]
}
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,