Skip to content
This repository was archived by the owner on Aug 24, 2020. It is now read-only.

Commit 4be755a

Browse files
Initial import (no dev yet)
0 parents  commit 4be755a

17 files changed

+750
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Node
2+
node_modules/*
3+
npm-debug.log
4+
5+
# TypeScript
6+
src/*.js
7+
src/*.map
8+
src/*.d.ts
9+
10+
# JetBrains
11+
.idea
12+
.project
13+
.settings
14+
.idea/*
15+
*.iml
16+
17+
# VS Code
18+
.vscode/*
19+
20+
# Windows
21+
Thumbs.db
22+
Desktop.ini
23+
24+
# Mac
25+
.DS_Store
26+
**/.DS_Store
27+
28+
# Ngc generated files
29+
**/*.ngfactory.ts
30+
31+
# Build files
32+
dist/*

.npmignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Node
2+
node_modules/*
3+
npm-debug.log
4+
5+
# DO NOT IGNORE TYPESCRIPT FILES FOR NPM
6+
# TypeScript
7+
# *.js
8+
# *.map
9+
# *.d.ts
10+
11+
# JetBrains
12+
.idea
13+
.project
14+
.settings
15+
.idea/*
16+
*.iml
17+
18+
# VS Code
19+
.vscode/*
20+
21+
# Windows
22+
Thumbs.db
23+
Desktop.ini
24+
25+
# Mac
26+
.DS_Store
27+
**/.DS_Store
28+
29+
# Ngc generated files
30+
**/*.ngfactory.ts
31+
32+
# Library files
33+
src/*
34+
build/*

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- '4.2.1'

.yo-rc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"generator-angular2-library": {
3+
"promptValues": {
4+
"gitRepositoryUrl": "https://github.com/peterpeterparker/ionic-swing.git"
5+
}
6+
}
7+
}

README.MD

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ionic-swing
2+
3+
## Installation
4+
5+
To install this library, run:
6+
7+
```bash
8+
$ npm install ionic-swing --save
9+
```
10+
11+
## Consuming your library
12+
13+
Once you have published your library to npm, you can import your library in any Angular application by running:
14+
15+
```bash
16+
$ npm install ionic-swing
17+
```
18+
19+
and then from your Angular `AppModule`:
20+
21+
```typescript
22+
import { BrowserModule } from '@angular/platform-browser';
23+
import { NgModule } from '@angular/core';
24+
25+
import { AppComponent } from './app.component';
26+
27+
// Import your library
28+
import { SampleModule } from 'ionic-swing';
29+
30+
@NgModule({
31+
declarations: [
32+
AppComponent
33+
],
34+
imports: [
35+
BrowserModule,
36+
37+
// Specify your library as an import
38+
LibraryModule
39+
],
40+
providers: [],
41+
bootstrap: [AppComponent]
42+
})
43+
export class AppModule { }
44+
```
45+
46+
Once your library is imported, you can use its components, directives and pipes in your Angular application:
47+
48+
```xml
49+
<!-- You can now use your library component in app.component.html -->
50+
<h1>
51+
{{title}}
52+
</h1>
53+
<sampleComponent></sampleComponent>
54+
```
55+
56+
## Development
57+
58+
To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:
59+
60+
```bash
61+
$ npm run build
62+
```
63+
64+
To lint all `*.ts` files:
65+
66+
```bash
67+
$ npm run lint
68+
```
69+
70+
## License
71+
72+
MIT © [David Dal Busco](mailto:[email protected])

gulpfile.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/* eslint-disable */
2+
var gulp = require('gulp'),
3+
path = require('path'),
4+
ngc = require('@angular/compiler-cli/src/main').main,
5+
rollup = require('gulp-rollup'),
6+
del = require('del'),
7+
runSequence = require('run-sequence'),
8+
inlineResources = require('./tools/gulp/inline-resources');
9+
10+
const rootFolder = path.join(__dirname);
11+
const srcFolder = path.join(rootFolder, 'src');
12+
const tmpFolder = path.join(rootFolder, '.tmp');
13+
const buildFolder = path.join(rootFolder, 'build');
14+
const distFolder = path.join(rootFolder, 'dist');
15+
16+
/**
17+
* 1. Delete /dist folder
18+
*/
19+
gulp.task('clean:dist', function () {
20+
return deleteFolders([distFolder]);
21+
});
22+
23+
/**
24+
* 2. Clone the /src folder into /.tmp. If an npm link inside /src has been made,
25+
* then it's likely that a node_modules folder exists. Ignore this folder
26+
* when copying to /.tmp.
27+
*/
28+
gulp.task('copy:source', function () {
29+
return gulp.src([`${srcFolder}/**/*`, `!${srcFolder}/node_modules`])
30+
.pipe(gulp.dest(tmpFolder));
31+
});
32+
33+
/**
34+
* 3. Inline template (.html) and style (.css) files into the the component .ts files.
35+
* We do this on the /.tmp folder to avoid editing the original /src files
36+
*/
37+
gulp.task('inline-resources', function () {
38+
return Promise.resolve()
39+
.then(() => inlineResources(tmpFolder));
40+
});
41+
42+
43+
/**
44+
* 4. Run the Angular compiler, ngc, on the /.tmp folder. This will output all
45+
* compiled modules to the /build folder.
46+
*/
47+
gulp.task('ngc', function () {
48+
return ngc({
49+
project: `${tmpFolder}/tsconfig.es5.json`
50+
})
51+
.then((exitCode) => {
52+
if (exitCode === 1) {
53+
// This error is caught in the 'compile' task by the runSequence method callback
54+
// so that when ngc fails to compile, the whole compile process stops running
55+
throw new Error('ngc compilation failed');
56+
}
57+
});
58+
});
59+
60+
/**
61+
* 5. Run rollup inside the /build folder to generate our Flat ES module and place the
62+
* generated file into the /dist folder
63+
*/
64+
gulp.task('rollup', function () {
65+
return gulp.src(`${buildFolder}/**/*.js`)
66+
// transform the files here.
67+
.pipe(rollup({
68+
// any option supported by Rollup can be set here.
69+
entry: `${buildFolder}/index.js`,
70+
external: [
71+
'@angular/core',
72+
'@angular/common'
73+
],
74+
format: 'es'
75+
}))
76+
.pipe(gulp.dest(distFolder));
77+
});
78+
79+
/**
80+
* 6. Copy all the files from /build to /dist, except .js files. We ignore all .js from /build
81+
* because with don't need individual modules anymore, just the Flat ES module generated
82+
* on step 5.
83+
*/
84+
gulp.task('copy:build', function () {
85+
return gulp.src([`${buildFolder}/**/*`, `!${buildFolder}/**/*.js`])
86+
.pipe(gulp.dest(distFolder));
87+
});
88+
89+
/**
90+
* 7. Copy package.json from /src to /dist
91+
*/
92+
gulp.task('copy:manifest', function () {
93+
return gulp.src([`${srcFolder}/package.json`])
94+
.pipe(gulp.dest(distFolder));
95+
});
96+
97+
/**
98+
* 8. Delete /.tmp folder
99+
*/
100+
gulp.task('clean:tmp', function () {
101+
return deleteFolders([tmpFolder]);
102+
});
103+
104+
/**
105+
* 9. Delete /build folder
106+
*/
107+
gulp.task('clean:build', function () {
108+
return deleteFolders([buildFolder]);
109+
});
110+
111+
gulp.task('compile', function () {
112+
runSequence(
113+
'clean:dist',
114+
'copy:source',
115+
'inline-resources',
116+
'ngc',
117+
'rollup',
118+
'copy:build',
119+
'copy:manifest',
120+
'clean:build',
121+
'clean:tmp',
122+
function (err) {
123+
if (err) {
124+
console.log('ERROR:', err.message);
125+
deleteFolders([distFolder, tmpFolder, buildFolder]);
126+
} else {
127+
console.log('Compilation finished succesfully');
128+
}
129+
});
130+
});
131+
132+
/**
133+
* Watch for any change in the /src folder and compile files
134+
*/
135+
gulp.task('watch', function () {
136+
gulp.watch(`${srcFolder}/**/*`, ['compile']);
137+
});
138+
139+
gulp.task('clean', ['clean:dist', 'clean:tmp', 'clean:build']);
140+
141+
gulp.task('build', ['clean', 'compile']);
142+
gulp.task('build:watch', ['build', 'watch']);
143+
gulp.task('default', ['build:watch']);
144+
145+
/**
146+
* Deletes the specified folder
147+
*/
148+
function deleteFolders(folders) {
149+
return del(folders);
150+
}

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "ionic-swing",
3+
"version": "0.1.0",
4+
"scripts": {
5+
"build": "gulp build",
6+
"build:watch": "gulp",
7+
"lint": "tslint --type-check --project tsconfig.json src/**/*.ts",
8+
"test": "tsc && karma start"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/peterpeterparker/ionic-swing.git"
13+
},
14+
"author": {
15+
"name": "David Dal Busco",
16+
"email": "[email protected]"
17+
},
18+
"keywords": [
19+
"angular"
20+
],
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/peterpeterparker/ionic-swing.git/issues"
24+
},
25+
"devDependencies": {
26+
"@angular/common": "^4.0.0",
27+
"@angular/compiler": "^4.0.0",
28+
"@angular/compiler-cli": "^4.0.0",
29+
"@angular/core": "^4.0.0",
30+
"@angular/platform-browser": "^4.0.0",
31+
"@angular/platform-browser-dynamic": "^4.0.0",
32+
"@types/jasmine": "2.5.38",
33+
"@types/node": "~6.0.60",
34+
"codelyzer": "~2.0.0",
35+
"core-js": "^2.4.1",
36+
"del": "^2.2.2",
37+
"gulp": "^3.9.1",
38+
"gulp-rollup": "^2.11.0",
39+
"jasmine-core": "~2.5.2",
40+
"jasmine-spec-reporter": "~3.2.0",
41+
"karma": "~1.4.1",
42+
"karma-chrome-launcher": "~2.0.0",
43+
"karma-cli": "~1.0.1",
44+
"karma-coverage-istanbul-reporter": "^0.2.0",
45+
"karma-jasmine": "~1.1.0",
46+
"karma-jasmine-html-reporter": "^0.2.2",
47+
"node-watch": "^0.5.2",
48+
"protractor": "~5.1.0",
49+
"rollup": "^0.41.6",
50+
"run-sequence": "^1.2.2",
51+
"rxjs": "^5.1.0",
52+
"ts-node": "~2.0.0",
53+
"tslint": "~4.5.0",
54+
"typescript": "~2.2.0",
55+
"zone.js": "^0.8.4"
56+
},
57+
"engines": {
58+
"node": ">=6.0.0"
59+
}
60+
}

0 commit comments

Comments
 (0)