Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/remove-scripts' into windows-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Jul 22, 2020
2 parents 5da4e0b + 2711f7e commit 75488b8
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 134 deletions.
3 changes: 1 addition & 2 deletions build/clean-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
// Implemented as a single script here so that it works on Windows, Linux and Mac

const path = require('path');
const fs = require('fs-extra');
const fs = require('fs');

// __dirname is the folder where build.js is located
const STRATOS_DIR= path.resolve(__dirname, '..');
const DEVKIT_DIST_DIR= path.join(STRATOS_DIR, 'dist-devkit');

function processFile(filepath) {
if (fs.existsSync(filepath)) {
Expand Down
30 changes: 30 additions & 0 deletions build/dev-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copy files required for developer quick start
// Implemented as a single script here so that it works on Windows, Linux and Mac

const path = require('path');
const fs = require('fs');

// __dirname is the folder where build.js is located
const STRATOS_DIR= path.resolve(__dirname, '..');

// Only copy files if they are not already there - just make sure initial versions are in place for developer

// Proxy config file
const PROXY_CONF = path.join(STRATOS_DIR, 'proxy.conf.js');
if (!fs.existsSync(PROXY_CONF)) {
let err = fs.copyFileSync(path.join(__dirname, 'proxy.conf.localdev.js'), PROXY_CONF);
if (err) {
console.log(err);
}
}

// config.properties
const BACKEND_DIR = path.join(STRATOS_DIR, 'src', 'jetstream');
const BACKEND_CONF = path.join(BACKEND_DIR, 'config.properties');
const BACKEND_CONF_DEV = path.join(BACKEND_DIR, 'config.dev');
if (!fs.existsSync(BACKEND_CONF)) {
let err = fs.copyFileSync(BACKEND_CONF_DEV, BACKEND_CONF);
if (err) {
console.log(err);
}
}
82 changes: 0 additions & 82 deletions build/fe-build.js

This file was deleted.

14 changes: 0 additions & 14 deletions build/gulp.config.js

This file was deleted.

16 changes: 16 additions & 0 deletions build/prebuild-zip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Zip the dist folder
// Implemented as a single script here so that it works on Windows, Linux and Mac

const path = require('path');
const fs = require('fs');
const AdmZip = require('adm-zip');

// __dirname is the folder where build.js is located
const STRATOS_DIR= path.resolve(__dirname, '..');
const DIST_DIR= path.join(STRATOS_DIR, 'dist');
const ZIP_FILE= path.join(STRATOS_DIR, 'stratos-frontend-prebuild.zip');

var zip = new AdmZip();

zip.addLocalFolder(DIST_DIR);
zip.writeZip(path.join(ZIP_FILE));
38 changes: 38 additions & 0 deletions build/store-git-metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Generate the git metadata file

// Implemented as a single script here so that it works on Windows, Linux and Mac

const path = require('path');
const fs = require('fs');
const execSync = require('child_process').execSync;

// __dirname is the folder where build.js is located
const STRATOS_DIR = path.resolve(__dirname, '..');
const GIT_FOLDER = path.join(STRATOS_DIR, '.git');
const GIT_METADATA = path.join(STRATOS_DIR, '.stratos-git-metadata.json');

function execGit(cmd) {
try {
var response = execSync(cmd);
return response.toString().trim();
} catch (e) {
console.log(e)
return '';
}
}

// We can only do this if we have a git repository checkout
// We'll store this in a file which we will then use - when in environments like Docker, we will run this
// in the host environment so that we can pick it up when we're running in the Docker world
// Do we have a git folder?
if (!fs.existsSync(GIT_FOLDER)) {
console.log(' + Unable to store git repository metadata - .git folder not found');
return;
}
var gitMetadata = {
project: execGit('git config --get remote.origin.url'),
branch: execGit('git rev-parse --abbrev-ref HEAD'),
commit: execGit('git rev-parse HEAD')
};

fs.writeFileSync(GIT_METADATA, JSON.stringify(gitMetadata, null, 2));
2 changes: 1 addition & 1 deletion deploy/stratos-ui-release/packages/backend/pre_packaging
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# Build backend
npm install
export PATH=$PATH:$PWD/node_modules/.bin
npm run bosh-build-backend
npm run build-backend

find ../stratos/deploy -type d ! -path '../stratos/deploy' ! -path '*/db' -maxdepth 1 | xargs rm -rf

Expand Down
4 changes: 2 additions & 2 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ db provider this can be done by deleting `src/jetstream/console-database.db`
#### Configure by Environment Variables and/or Config File
By default, the configuration in file `src/jetstream/default.config.properties` will be used. These can be changed by environment variables
By default, the configuration in file `src/jetstream/config.properties` will be used. These can be changed by environment variables
or an overrides file.
##### Environment variable
Expand All @@ -238,7 +238,7 @@ If you have a custom uaa, ensure you have set the following environment variable
##### Config File
To easily persist configuration settings copy `src/jetstream/default.config.properties` to `src/jetstream/config.properties`. The backend will load its
To easily persist configuration settings copy `src/jetstream/config.example` to `src/jetstream/config.properties`. The backend will load its
configuration from this file in preference to the default config file, if it exists. You can also modify individual configuration settings
by setting the corresponding environment variable.
Expand Down
4 changes: 0 additions & 4 deletions gulpfile.js

This file was deleted.

24 changes: 12 additions & 12 deletions package-lock.json

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

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"build-backend": "cd build && bk-build.sh",
"full-build-dev": "npm run build-dev; npm run build-backend",
"fetch-backend-deps": "cd build && bk-fetch-deps.sh",
"bosh-build-backend": "gulp bosh-build-backend",
"test-backend": "cd build && bk-build.sh test",
"update-webdriver": "webdriver-manager update",
"build": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod",
"build-cf": "node --max_old_space_size=1500 --gc_interval=100 node_modules/@angular/cli/bin/ng build --prod",
"build-dev": "ng build --dev",
"prebuild-ui": "npm run build && gulp package-prebuild",
"prebuild-zip": "node build/prebuild-zip.js",
"ng": "ng",
"start": "ng serve",
"start-high-mem": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve",
Expand All @@ -37,10 +37,11 @@
"headless-e2e": "xvfb-run --server-args='-screen 0 1920x1080x24' protractor ./protractor.conf.js",
"climate": "codeclimate analyze $(git diff --name-only master)",
"gate-check": "npm run lint && npm run test-headless",
"store-git-metadata": "gulp store-git-metadata",
"postinstall": "gulp dev-setup && npm run build-devkit && npm run clean-symlinks",
"store-git-metadata": "node build/store-git-metadata.js",
"postinstall": "npm run dev-setup && npm run build-devkit && npm run clean-symlinks && npm run store-git-metadata",
"build-devkit": "cd src/frontend/packages/devkit && npm run build",
"clean-symlinks": "node build/clean-symlinks.js"
"clean-symlinks": "node build/clean-symlinks.js",
"dev-setup": "node build/dev-setup.js"
},
"author": "",
"license": "Apache-2.0",
Expand Down Expand Up @@ -109,15 +110,14 @@
"@types/node": "^13.11.1",
"@types/request": "^2.48.4",
"acorn": "^7.1.1",
"adm-zip": "^0.4.16",
"browserstack-local": "^1.4.5",
"codecov": "^3.6.5",
"codecov": "^3.7.1",
"codelyzer": "^5.1.2",
"copy-webpack-plugin": "5.1.1",
"delete": "^1.1.0",
"fs-extra": "^9.0.0",
"globby": "^11.0.0",
"gulp": "^4.0.2",
"gulp-zip": "^5.0.1",
"istanbul": "^0.4.5",
"istanbul-api": "2.1.6",
"istanbul-reports": "3.0.2",
Expand All @@ -143,7 +143,6 @@
"protractor": "^5.4.3",
"ps-node": "^0.1.6",
"q": "^1.4.1",
"replace-in-file": "^5.0.2",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"rxjs-tslint": "^0.1.8",
Expand Down
16 changes: 14 additions & 2 deletions src/frontend/packages/devkit/src/build/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as fs from 'fs';
import * as path from 'path';
import { NormalModuleReplacementPlugin } from 'webpack';

import { NormalModuleReplacementPlugin } from 'webpack';
import { StratosConfig } from '../lib/stratos.config';

const importModuleRegex = /src\/frontend\/packages\/core\/src\/custom-import.module.ts/;

const isWindows = process.platform === 'win32';

/**
* Generates the file _custom-import.module.ts containing the code to import
* the extensions modules discovered from the packages being included.
Expand Down Expand Up @@ -51,8 +53,18 @@ export class ExtensionsHandler {
this.writeModule(overrideFile, 'CustomImportModule', moduleImports);
this.writeModule(overrideFile, 'CustomRoutingImportModule', routingMmoduleImports);

let regex;
// On windows, use an absolute path with backslashes escaped
if (isWindows) {
let p = path.resolve(path.join(dir, 'custom-import.module.ts'));
p = p.replace(/\\/g, '\\\\');
regex = new RegExp(p);
} else {
regex = importModuleRegex
}

webpackConfig.plugins.push(new NormalModuleReplacementPlugin(
importModuleRegex,
regex,
overrideFile
));
}
Expand Down
Loading

0 comments on commit 75488b8

Please sign in to comment.