diff --git a/packages/angular/package.json b/packages/angular/package.json index ee687fda75..db70c35f8e 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -21,6 +21,7 @@ }, "scripts": { "build": "npm run clean && npm run compile && npm run clean-generated", + "build.link": "node scripts/link-copy.js", "clean": "node scripts/clean.js", "clean-generated": "node ./scripts/clean-generated.js", "compile": "./node_modules/.bin/ngc", diff --git a/packages/angular/scripts/README.md b/packages/angular/scripts/README.md index 4caa53d311..a84aa36299 100644 --- a/packages/angular/scripts/README.md +++ b/packages/angular/scripts/README.md @@ -1,3 +1,12 @@ +# npm link local development + +`npm link` doesn't work as expected due to the `devDependency` on `@angular/core`. This is the work around... + + npm run build.link ../ionic-conference-app + +When the command above is ran from the `packages/angular` directory, it will build `@ionic/angular` and copy the `dist` directory to the correct location of another local project. In the example above, the end result is that it copies the `dist` directory to `../ionic-conference-app/node_modules/@ionic/angular/dist`. The path given should be relative to the root of this mono repo. + + # Deploy 1. `npm run prepare.deploy` diff --git a/packages/angular/scripts/link-copy.js b/packages/angular/scripts/link-copy.js new file mode 100644 index 0000000000..b7fcc359c3 --- /dev/null +++ b/packages/angular/scripts/link-copy.js @@ -0,0 +1,31 @@ +const fs = require('fs-extra'); +const path = require('path'); + + +let prjDir = process.argv[2]; +if (!prjDir) { + throw new Error('local path required as last argument to "npm run build.link" command'); +} +prjDir = path.join(__dirname, '../../../', prjDir); +const prjIonicAngular = path.join(prjDir, 'node_modules/@ionic/angular'); + +const ionicAngularDir = path.join(__dirname, '..'); +const ionicAngularDist = path.join(ionicAngularDir, 'dist'); +const ionicAngularPkgJsonPath = path.join(ionicAngularDir, 'package.json'); +const ionicAngularPkgJson = require(ionicAngularPkgJsonPath); + +// make sure this local project exists +fs.emptyDirSync(prjIonicAngular); + +ionicAngularPkgJson.files.push('package.json'); + +ionicAngularPkgJson.files.forEach(f => { + const src = path.join(ionicAngularDir, f); + const dest = path.join(prjIonicAngular, f); + + console.log('copying:', src, 'to', dest); + fs.copySync(src, dest); +}); + +const prjReadme = path.join(prjIonicAngular, 'README.md'); +fs.writeFileSync(prjReadme, '@ionic/angular copied from ' + ionicAngularDir);