Skip to content

Commit

Permalink
align packages with Angular Package Format
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsoni119 committed Mar 7, 2020
1 parent 2b7eca2 commit f97aa18
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
npm-debug.log
node_modules
jspm_packages
tmp
/dist
*.metadata.json
.idea
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ telInputObject(obj) {
}
```

![N|Solid](./example.png)
![N|Solid](https://raw.githubusercontent.com/gauravsoni119/ng2-tel-input/master/example.png)
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.0] - 2020-3-08
### Changed
- Align packages with Angular Package Format

## [2.2.0] - 2020-2-29
### Changed
- Revert dependency of angular to 8
49 changes: 44 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ const compile = async (cb) => {
}

/**
* copy package.jsona and README.md, and example.png to package
* copy assets to package
* @param {Function} cb needs to execute at the end of the function
*/
copy = (cb) => {
const stream = src(['./package.json', './README.md', './example.png']).pipe(dest('./dist'));
const copyAssets = (cb) => {
const stream = src(['tmp/esm2015/*.d.ts', 'tmp/esm2015/*.json','./package.json', './README.md']).pipe(dest('dist/'));
stream.on('end', () => cb());
};

/**
* copy declarations(d.ts) files to package
* @param {Function} cb needs to execute at the end of the function
*/
const copySrcDeclarations = (cb) => {
src('tmp/esm2015/src/*.d.ts').pipe(dest('dist/src'));
cb();
};

/**
* Run yarn pack command to create .tar file so that we can install package locally and test it
* @param {Function} cb needs to execute at the end of the function
Expand All @@ -72,6 +81,15 @@ const cleanDist = (cb) => {
cb();
};

/**
* Remove tmp folder
* @param {Function} cb needs to execute at the end of the function
*/
const cleanTmp = (cb) => {
src(path.resolve(__dirname, 'tmp')).pipe(clean());
cb();
};

/**
* Wrapp readFile function inside promise so that we can use promises
* @param {string} path of the file
Expand All @@ -96,10 +114,31 @@ const updatePackageJson = async (cb) => {
const packageFile = JSON.parse(file);
packageFile.devDependencies = {};
packageFile.scripts = {};
packageFile.main = "./bundles/ng2-tel-input.umd.min.js";
packageFile.module = "./esm5/ng2-tel-input.js";
packageFile.es2015 = "./esm2015/ng2-tel-input.js";
packageFile.typings = "./ng2-tel-input.d.ts";
const data = JSON.stringify(packageFile, null, 2);
fs.writeFileSync(path.resolve(`${__dirname}/dist`, 'package.json'), data);
cb();
};

exports.buildDev = series(cleanDist, compile, copy, updatePackageJson, pack);
exports.default = series(cleanDist, compile, copy, updatePackageJson);
/**
* Create tmp direcatory in root folder and copy the src into the tmp src directory
* @param {Function} cb The callback that needs to execute at the end of function
*/
const createTempDir = async (cb) => {
src(['./src/**/*.ts']).pipe(dest('./tmp/src'));
};

/**
* Copy the public_api.ts file into the tmp directory
* @param {Function} cb The callback that needs to execute at the end of function
*/
const copyPublicApi = async (cb) => {
src(['./public_api.ts']).pipe(dest('./tmp'));
};


exports.buildDev = series(cleanDist, createTempDir, copyPublicApi, compile, copyAssets, copySrcDeclarations, updatePackageJson, cleanTmp, pack);
exports.default = series(cleanDist, createTempDir, copyPublicApi, compile, copyAssets, copySrcDeclarations, updatePackageJson, cleanTmp);
2 changes: 0 additions & 2 deletions ng2-tel-input.ts

This file was deleted.

42 changes: 41 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
"scripts": {
"watch": "tsc -p src -w",
"start": "http-server -c-1 .",
"build": "ngc -p ./tsconfig-ngc.json",
"build": "npm run build:esm2015 && npm run build:fesm2015 && npm run build:esm5 && npm run build:fesm5 && npm run build:umd && npm run build:umd:min",
"build:prod": "gulp",
"build:dev": "gulp buildDev",
"createTemp": "gulp createTemp",
"build:esm2015": "ngc -p tsconfig-esm2015.json",
"build:fesm2015": "rollup -c rollup-esm2015.conf.js",
"build:esm5": "ngc -p tsconfig-esm5.json",
"build:fesm5": "rollup -c rollup-esm5.conf.js",
"build:umd": "rollup -c rollup-umd.conf.js",
"build:umd:min": "uglifyjs dist/bundles/ng2-tel-input.umd.js -c -m -o dist/bundles/ng2-tel-input.umd.min.js",
"ls": "gulp --tasks"
},
"repository": {
Expand All @@ -35,15 +42,17 @@
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"reflect-metadata": "^0.1.13",
"rollup": "^2.0.2",
"rxjs": "^6.5.2",
"tsickle": "^0.38.1",
"typescript": "~3.4.5",
"uglify-js": "^3.8.0",
"zone.js": "^0.9.1"
},
"peerDependencies": {
"@angular/core": "^8.0.3"
},
"dependencies": {
"intl-tel-input": "^16.0.0"
},
"typings": "./ng2-tel-input.d.ts"
}
}
1 change: 1 addition & 0 deletions public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/index';
4 changes: 4 additions & 0 deletions rollup-esm2015.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
input: 'tmp/esm2015/ng2-tel-input.js',
output: { file: 'dist/esm2015/ng2-tel-input.js', format: 'es' },
};
4 changes: 4 additions & 0 deletions rollup-esm5.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
input: 'tmp/esm5/ng2-tel-input.js',
output: { file: 'dist/esm5/ng2-tel-input.js', format: 'es' },
};
7 changes: 7 additions & 0 deletions rollup-umd.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
input: 'tmp/esm5/ng2-tel-input.js',
output: { file: 'dist/bundles/ng2-tel-input.umd.js', name: 'Ng2TelInput', format: 'umd' },
globals: {
'@angular/core': 'ng.core'
}
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Ng2TelInputModule } from './ng2-tel-input.module';
export { Ng2TelInput } from './ng2-tel-input';
2 changes: 1 addition & 1 deletion src/ng2-tel-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultUtilScript = 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input
selector: '[ng2TelInput]',
})
export class Ng2TelInput implements OnInit {
@Input('ng2TelInputOptions') ng2TelInputOptions: any = {};
@Input('ng2TelInputOptions') ng2TelInputOptions: { [key: string]: any } = {};
@Output('hasError') hasError: EventEmitter<boolean> = new EventEmitter();
@Output('ng2TelOutput') ng2TelOutput: EventEmitter<any> = new EventEmitter();
@Output('countryChange') countryChange: EventEmitter<any> = new EventEmitter();
Expand Down
14 changes: 8 additions & 6 deletions tsconfig-ngc.json → tsconfig-esm2015.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2015",
"module": "es2015",
"lib": [ "es2015", "dom" ],
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"declaration": true,
"stripInternal": true,
"outDir": "./dist"
"outDir": "./tmp/esm2015",
"rootDir": "./tmp"
},
"exclude": [
"node_modules"
],
"files": [
"./ng2-tel-input.ts"
"./tmp/public_api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true
"skipTemplateCodegen": true,
"flatModuleOutFile": "ng2-tel-input.js",
"flatModuleId": "ng2-tel-input",
}
}
15 changes: 15 additions & 0 deletions tsconfig-esm5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig-esm2015.json",
"compilerOptions": {
"target": "es5",
"outDir": "./tmp/esm5",
"rootDir": "./tmp"
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"flatModuleOutFile": "ng2-tel-input.js",
"flatModuleId": "ng2-tel-input",
}
}
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"sourceMap": true,
"declaration": true
},
"files": [
"ng2-tel-input.ts"
],
"exclude": [
"node_modules"
]
Expand Down
32 changes: 31 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ color-support@^1.1.3:
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==

commander@~2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

component-emitter@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
Expand Down Expand Up @@ -836,6 +841,11 @@ fsevents@^1.2.7:
bindings "^1.5.0"
nan "^2.12.1"

fsevents@~2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805"
integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
Expand Down Expand Up @@ -2012,6 +2022,13 @@ rimraf@^2.6.2:
dependencies:
glob "^7.1.3"

rollup@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.0.2.tgz#0f63aa02bb106802a387380ee88b90b5c0449eaa"
integrity sha512-99VIc2DHm+HEhdla2ASH/LaomWS3v7RDANamD65w24TQTNVs3vtRM+oiFsP4KvUCri5+p5Q5xoXscUnIdE8gJA==
optionalDependencies:
fsevents "~2.1.2"

rxjs@^6.5.2:
version "6.5.4"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c"
Expand Down Expand Up @@ -2129,7 +2146,7 @@ source-map@^0.5.6:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=

source-map@^0.6.1:
source-map@^0.6.1, source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
Expand Down Expand Up @@ -2339,6 +2356,11 @@ to-through@^2.0.0:
dependencies:
through2 "^2.0.3"

tsickle@^0.38.1:
version "0.38.1"
resolved "https://registry.yarnpkg.com/tsickle/-/tsickle-0.38.1.tgz#30762db759d40c435943093b6972c7f2efb384ef"
integrity sha512-4xZfvC6+etRu6ivKCNqMOd1FqcY/m6JY3Y+yr5+Xw+i751ciwrWINi6x/3l1ekcODH9GZhlf0ny2LpzWxnjWYA==

tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
Expand All @@ -2363,6 +2385,14 @@ typescript@~3.4.5:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==

uglify-js@^3.8.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.8.0.tgz#f3541ae97b2f048d7e7e3aa4f39fd8a1f5d7a805"
integrity sha512-ugNSTT8ierCsDHso2jkBHXYrU8Y5/fY2ZUprfrJUiD7YpuFvV4jODLFmb3h4btQjqr5Nh4TX4XtgDfCU1WdioQ==
dependencies:
commander "~2.20.3"
source-map "~0.6.1"

unc-path-regex@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa"
Expand Down

0 comments on commit f97aa18

Please sign in to comment.