Skip to content

Commit

Permalink
Pre-release preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Nov 16, 2017
1 parent d08c0e5 commit fed41c7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
File renamed without changes.
35 changes: 32 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const sourcemaps = require('rollup-plugin-sourcemaps');
const inlineResources = require('./inline-resources');


const DIST_FOLDER_NAME = 'dist';

const libName = require('./package.json').name;
const rootFolder = path.join(__dirname);
const compilationFolder = path.join(rootFolder, 'out-tsc');
const srcFolder = path.join(rootFolder, 'src/lib');
const distFolder = path.join(rootFolder, 'dist');
const distFolder = path.join(rootFolder, DIST_FOLDER_NAME);
const tempLibFolder = path.join(compilationFolder, 'lib');
const es5OutputFolder = path.join(compilationFolder, 'lib-es5');
const es2015OutputFolder = path.join(compilationFolder, 'lib-es2015');
Expand Down Expand Up @@ -120,8 +122,8 @@ return Promise.resolve()
// Copy package files
.then(() => Promise.resolve()
.then(() => _relativeCopy('LICENSE', rootFolder, distFolder))
.then(() => _relativeCopy('package.json', rootFolder, distFolder))
.then(() => _relativeCopy('README.md', rootFolder, distFolder))
.then(() => _relativeCopy('README.adoc', rootFolder, distFolder))
.then(() => _generatePackageJson(path.join(rootFolder, 'package.json'), distFolder))
.then(() => console.log('Package files copy succeeded.'))
)
.catch(e => {
Expand All @@ -148,6 +150,33 @@ function _relativeCopy(fileGlob, from, to) {
});
}

function _generatePackageJson(basePackageJson, distFolder) {
return new Promise((resolve, reject) => {
try {
const json = JSON.parse(fs.readFileSync(basePackageJson));
if (json['scripts']) {
delete json['scripts']['postinstall'];
}
const searchValue = './' + DIST_FOLDER_NAME + '/';
const replaceValue = './';
replacePropertyValue(json, 'main', searchValue, replaceValue);
replacePropertyValue(json, 'module', searchValue, replaceValue);
replacePropertyValue(json, 'es2015', searchValue, replaceValue);
replacePropertyValue(json, 'typings', searchValue, replaceValue);
fs.writeFileSync(path.join(distFolder, 'package.json'), JSON.stringify(json, null, 2));
resolve();
} catch (error) {
reject(error);
}
});
}

function replacePropertyValue(json, property, searchValue, newValue) {
if (typeof json[property] === 'string') {
json[property] = json[property].replace(searchValue, newValue);
}
}

// Recursively create a dir.
function _recursiveMkDir(dir) {
if (!fs.existsSync(dir)) {
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spring-flo",
"version": "0.7.0",
"version": "0.7.0-beta",
"description": "Library for quickly building text DSL visualization diagram editor",
"main": "./dist/bundles/spring-flo.umd.js",
"module": "./dist/spring-flo.es5.js",
Expand Down Expand Up @@ -40,9 +40,9 @@
"postinstall": "postinstall-build --only-as-dependency dist \"npm run build && node postinstall.js\""
},
"dependencies": {
"@angular/core": "4.2.4",
"@angular/forms": "4.2.4",
"@angular/platform-browser": "4.2.4",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@types/codemirror": "0.0.45",
"@types/jointjs": "1.0.4",
"@types/lodash": "4.14.73",
Expand All @@ -57,13 +57,14 @@
"@angular/animations": "4.2.4"
},
"devDependencies": {
"@angular/common": "4.2.4",
"@angular/compiler": "4.2.4",
"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.2.4",
"@angular/platform-browser": "4.2.4",
"@angular/platform-browser-dynamic": "4.2.4",
"@angular/platform-server": "4.2.4",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@angular/platform-server": "4.4.6",
"@types/jasmine": "2.5.36",
"@types/node": "6.0.46",
"camelcase": "4.0.0",
Expand All @@ -89,7 +90,6 @@
"tslint": "5.3.2",
"typescript": "2.3.3",
"zone.js": "0.8.14",
"@angular/forms": "4.2.4",
"@types/codemirror": "0.0.45",
"@types/jointjs": "1.0.4",
"@types/lodash": "4.14.73",
Expand Down

0 comments on commit fed41c7

Please sign in to comment.