@@ -12,15 +12,13 @@ const fse = require('fs-extra');
1212const path = require ( 'path' ) ;
1313const Gaze = require ( 'gaze' ) . Gaze ;
1414const argv = require ( 'yargs' ) . argv
15- const NGC_BINARY = '.. /library-build-chain/node_modules/.bin/ngc' ;
16- const ROLLUP_BINARY = '.. /library-build-chain/node_modules/.bin/rollup' ;
15+ const NGC_BINARY = './node_modules/@cloukit /library-build-chain/node_modules/.bin/ngc' ;
16+ const ROLLUP_BINARY = './node_modules/@cloukit /library-build-chain/node_modules/.bin/rollup' ;
1717const tsconfigTemplate = require ( './build-tsconfig-template.js' ) ;
1818const packageJsonTemplate = require ( './build-package-json-template.js' ) ;
1919const currentDir = shell . pwd ( ) . stdout ;
2020const relativePath = ( _path ) => {
2121 const absolutePath = path . resolve ( currentDir , _path ) ;
22- console . log ( absolutePath ) ;
23- process . exit ( ) ;
2422 return absolutePath ;
2523}
2624
@@ -33,33 +31,10 @@ const buildPackage = (languageTarget, watch) => {
3331 //
3432 // CLEANUP COPY SRC CONTENTS TO BUILD
3533 //
36- if ( shell . test ( '-d' , relativePath ( '../build/src' ) ) ) shell . rm ( '-rf' , relativePath ( '../build/src' ) ) ;
37- if ( shell . test ( '-f' , relativePath ( '../build/package-lock.json' ) ) ) shell . rm ( '-rf' , relativePath ( '../build/package-lock.json' ) ) ;
38- if ( ! shell . test ( '-d' , relativePath ( '../build/' ) ) ) shell . mkdir ( relativePath ( '../build/' ) ) ;
39- shell . cp ( '-R' , relativePath ( '../src' ) , relativePath ( '../build' ) ) ;
40- shell . cp ( '-R' , relativePath ( '../package.json' ) , relativePath ( '../build/package_orig.json' ) ) ;
34+ if ( ! shell . test ( '-d' , relativePath ( './build/' ) ) ) shell . mkdir ( relativePath ( './build/' ) ) ;
4135
42- //
43- // CD BUILD DIR
44- //
45- shell . cd ( relativePath ( '../build/' ) ) ;
46- const manifest = JSON . parse ( shell . cat ( relativePath ( '../build/package_orig.json' ) ) ) ;
36+ const manifest = JSON . parse ( shell . cat ( relativePath ( './package.json' ) ) ) ;
4737
48- //
49- // GENERATE TEMPORARY LIBRARY package.json TO INSTALL PEER DEPENDENCIES DURING BUILD
50- //
51- if ( ! watch && languageTarget === 'es5' ) {
52- let packageJson = packageJsonTemplate . generate ( manifest . moduleId , manifest . version , manifest . description , 'devDependencies' , Object . assign ( { } , manifest . peerDependencies , manifest . devDependencies ) , 'dependencies' , manifest . dependencies , 'peerDependencies' , { } ) ;
53- fs . writeFileSync ( relativePath ( `../build/package.json` ) , JSON . stringify ( packageJson , null , 2 ) ) ;
54- shell . echo ( chalk . blue ( '>> ==============' ) ) ;
55- shell . echo ( chalk . blue ( '>> YARN INSTALL' ) ) ;
56- shell . echo ( chalk . blue ( '>> ==============' ) ) ;
57- const npmInstallResult = shell . exec ( 'yarn install' ) ;
58- if ( npmInstallResult . code !== 0 ) {
59- shell . echo ( chalk . red ( "YARN ERROR. STOP!" ) ) ;
60- return ;
61- }
62- }
6338
6439 //
6540 // BUILD OR WATCH
@@ -73,21 +48,24 @@ const buildPackage = (languageTarget, watch) => {
7348 // WRITE TSCONFIGS
7449 //
7550 const tsConfig = tsconfigTemplate . generate ( languageTarget , manifest . moduleId ) ;
76- fs . writeFileSync ( relativePath ( `../build /tsconfig-${ languageTarget } .json` ) , JSON . stringify ( tsConfig , null , 2 ) ) ;
51+ fs . writeFileSync ( relativePath ( `./tsconfig-${ languageTarget } .json` ) , JSON . stringify ( tsConfig , null , 2 ) ) ;
7752
7853 //
7954 // BUILD WITH ANGULAR COMPILER
8055 //
81- const buildResult = shell . exec ( `${ NGC_BINARY } -p tsconfig-${ languageTarget } .json` ) ;
56+ const buildResult = shell . exec ( `${ NGC_BINARY } -p ./tsconfig-${ languageTarget } .json` ) ;
57+
8258 if ( buildResult . code !== 0 ) {
8359 shell . echo ( chalk . red ( "NGC ERROR. STOP!" ) ) ;
8460 return ;
61+ } else {
62+ shell . echo ( chalk . green ( buildResult . stdout ) ) ;
8563 }
8664
8765 //
8866 // BUILD FLAT ONE FILE MODULE WITH ROLLUP
8967 //
90- const rollupResult = shell . exec ( `${ ROLLUP_BINARY } _${ languageTarget } /src/${ manifest . moduleId } .js -o . ./dist/${ manifest . moduleId } .${ languageTarget } .js` ) ;
68+ const rollupResult = shell . exec ( `${ ROLLUP_BINARY } ./build/ _${ languageTarget } /src/${ manifest . moduleId } .js -o ./dist/${ manifest . moduleId } .${ languageTarget } .js` ) ;
9169 if ( rollupResult . code !== 0 ) {
9270 shell . echo ( chalk . red ( "ROLLUP ERROR. STOP!" ) ) ;
9371 return ;
@@ -102,27 +80,28 @@ const buildPackage = (languageTarget, watch) => {
10280 // WRITE FINAL LIB package.json
10381 //
10482 packageJson = packageJsonTemplate . generate ( manifest . moduleId , manifest . version , manifest . description , 'peerDependencies' , manifest . peerDependencies , 'dependencies' , manifest . dependencies , 'devDependencies' , manifest . devDependencies ) ;
105- fs . writeFileSync ( relativePath ( '.. /dist/package.json' ) , JSON . stringify ( packageJson , null , 2 ) ) ;
83+ fs . writeFileSync ( relativePath ( './dist/package.json' ) , JSON . stringify ( packageJson , null , 2 ) ) ;
10684
10785 //
10886 // COPY METADATA FILE FOR TREE SHAKING
10987 //
110- shell . cp ( `_es2015/src/${ manifest . moduleId } .metadata.json` , `. ./dist/${ manifest . moduleId } .metadata.json` ) ;
88+ shell . cp ( `./build/ _es2015/src/${ manifest . moduleId } .metadata.json` , `./dist/${ manifest . moduleId } .metadata.json` ) ;
11189
11290 //
11391 // COPY README
11492 //
115- shell . cp ( `.. /README.md` , `. ./dist/` ) ;
93+ shell . cp ( `./README.md` , `./dist/` ) ;
11694
11795 //
11896 // FIXME: SINCE WE CANNOT CREATE A TYPE-DEFINITION-BUNDLE FILE (YET) WE NEED TO COPY ALL *.d.ts FILES MANUALLY TO DIST
11997 //
12098 shell . echo ( chalk . blue ( '>> ==============' ) ) ;
12199 shell . echo ( chalk . blue ( `>> D.TS FILES` ) ) ;
122100 shell . echo ( chalk . blue ( '>> ==============' ) ) ;
123- fse . copySync ( relativePath ( '.. /build/_es2015/src' ) , relativePath ( '. ./dist' ) , {
101+ fse . copySync ( relativePath ( './build/_es2015/src' ) , relativePath ( './dist' ) , {
124102 filter : file => / ^ .* [ . ] t s $ / . test ( file ) || shell . test ( '-d' , file ) // *.d.ts files and folders!
125103 } ) ;
104+ shell . echo ( chalk . green ( 'done' ) ) ;
126105
127106 //
128107 // COMPODOC
@@ -132,30 +111,28 @@ const buildPackage = (languageTarget, watch) => {
132111 shell . echo ( chalk . blue ( '>> ==============' ) ) ;
133112
134113 // PATCH CDN URLS
135- if ( shell . test ( '-d' , relativePath ( '.. /documentation' ) ) ) shell . rm ( '-rf' , relativePath ( '. ./documentation/' ) ) ;
136- shell . cd ( relativePath ( '../build ' ) ) ;
114+ if ( shell . test ( '-d' , relativePath ( './documentation' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/' ) ) ;
115+ shell . cd ( relativePath ( './ ' ) ) ;
137116 const cdnUrl = 'https://cloukit.github.io/compodoc-theme/theme/1.0.0-beta.10' ;
138117 const templateFiles = [ 'page.hbs' , 'partials/component.hbs' , 'partials/module.hbs' , 'partials/routes.hbs' , 'partials/overview.hbs' ] ;
139118 for ( let i = 0 ; i < templateFiles . length ; i ++ ) {
140- shell . exec ( `sed -i -e 's@src="[^"]*js/@src="${ cdnUrl } /dist/js/@g' ../library-build-chain /node_modules/compodoc/src/templates/${ templateFiles [ i ] } ` ) ;
119+ shell . exec ( `sed -i -e 's@src="[^"]*js/@src="${ cdnUrl } /dist/js/@g' ./node_modules/compodoc/src/templates/${ templateFiles [ i ] } ` ) ;
141120 }
142- shell . exec ( `sed -i -e 's@href="[^"]*styles/style.css@href="${ cdnUrl } /style.css@g' ../library-build-chain /node_modules/compodoc/src/templates/page.hbs` ) ;
143- shell . exec ( `sed -i -e 's@href="[^"]*images/favicon.ico@href="${ cdnUrl } /images/favicon.ico@g' ../library-build-chain /node_modules/compodoc/src/templates/page.hbs` ) ;
144- shell . exec ( `sed -i -e 's@src="[^"]*images/compodoc-vectorise.svg@src="${ cdnUrl } /images/compodoc-logo.svg@g' ../library-build-chain /node_modules/compodoc/src/templates/partials/menu.hbs` ) ;
121+ shell . exec ( `sed -i -e 's@href="[^"]*styles/style.css@href="${ cdnUrl } /style.css@g' ./node_modules/compodoc/src/templates/page.hbs` ) ;
122+ shell . exec ( `sed -i -e 's@href="[^"]*images/favicon.ico@href="${ cdnUrl } /images/favicon.ico@g' ./node_modules/compodoc/src/templates/page.hbs` ) ;
123+ shell . exec ( `sed -i -e 's@src="[^"]*images/compodoc-vectorise.svg@src="${ cdnUrl } /images/compodoc-logo.svg@g' ./node_modules/compodoc/src/templates/partials/menu.hbs` ) ;
145124
146125 // EXECUTE COMPODOC
147126 if ( ! argv . watch ) {
148- shell . cd ( relativePath ( '../build' ) ) ;
149- const compodocResult = shell . exec ( `../library-build-chain/node_modules/compodoc/bin/index-cli.js --tsconfig tsconfig-es5.json --disableCoverage --disablePrivateOrInternalSupport --name "${ packageJson . name } v${ packageJson . version } " src` ) ;
127+ const compodocResult = shell . exec ( `./node_modules/compodoc/bin/index-cli.js --tsconfig tsconfig-es5.json --disableCoverage --disablePrivateOrInternalSupport --name "${ packageJson . name } v${ packageJson . version } " src` ) ;
150128 if ( compodocResult . code !== 0 ) {
151129 shell . echo ( chalk . red ( "COMPODOC ERROR. STOP!" ) ) ;
152130 return ;
153131 }
154- shell . mv ( relativePath ( '../build/documentation' ) , relativePath ( '../' ) ) ;
155- if ( shell . test ( '-d' , relativePath ( '../documentation/fonts/' ) ) ) shell . rm ( '-rf' , relativePath ( '../documentation/fonts/' ) ) ;
156- if ( shell . test ( '-d' , relativePath ( '../documentation/images/' ) ) ) shell . rm ( '-rf' , relativePath ( '../documentation/images/' ) ) ;
157- if ( shell . test ( '-d' , relativePath ( '../documentation/styles/' ) ) ) shell . rm ( '-rf' , relativePath ( '../documentation/styles/' ) ) ;
158- if ( shell . test ( '-d' , relativePath ( '../documentation/js/' ) ) ) shell . rm ( '-rf' , relativePath ( '../documentation/js/' ) ) ;
132+ if ( shell . test ( '-d' , relativePath ( './documentation/fonts/' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/fonts/' ) ) ;
133+ if ( shell . test ( '-d' , relativePath ( './documentation/images/' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/images/' ) ) ;
134+ if ( shell . test ( '-d' , relativePath ( './documentation/styles/' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/styles/' ) ) ;
135+ if ( shell . test ( '-d' , relativePath ( './documentation/js/' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/js/' ) ) ;
159136 }
160137
161138}
@@ -165,13 +142,13 @@ const buildPackage = (languageTarget, watch) => {
165142// INIT
166143//
167144const initialCleanup = ( ) => {
168- if ( shell . test ( '-d' , relativePath ( '.. /documentation' ) ) ) shell . rm ( '-rf' , relativePath ( '. ./documentation/' ) ) ;
169- if ( shell . test ( '-d' , relativePath ( '.. /dist' ) ) ) shell . rm ( '-rf' , relativePath ( '. ./dist/' ) ) ;
170- shell . mkdir ( relativePath ( '.. /dist/' ) ) ;
145+ if ( shell . test ( '-d' , relativePath ( './documentation' ) ) ) shell . rm ( '-rf' , relativePath ( './documentation/' ) ) ;
146+ if ( shell . test ( '-d' , relativePath ( './dist' ) ) ) shell . rm ( '-rf' , relativePath ( './dist/' ) ) ;
147+ shell . mkdir ( relativePath ( './dist/' ) ) ;
171148} ;
172149
173150if ( argv . watch ) {
174- var gaze = new Gaze ( '.. /src/**/*' ) ;
151+ var gaze = new Gaze ( './src/**/*' ) ;
175152 gaze . on ( 'all' , ( event , filepath ) => {
176153 try {
177154 //initialCleanup();
0 commit comments