Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Dec 15, 2020
2 parents 3aaa345 + 642713e commit 2ff5a4a
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bin/main.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion bin/root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scripts": {
"build": "npm run clean && webpack",
"build:prod": "npm run clean && cross-env NODE_ENV=production webpack --bail --progress",
"deploy": "node tools/deploy.js",
"resx": "node tools/resx.js",
"setFormCustomizable:true": "node tools/setFormCustomizable.js --customizable true",
"setFormCustomizable:false": "node tools/setFormCustomizable.js --customizable false",
Expand Down
1 change: 0 additions & 1 deletion bin/root/tools/deploy.js

This file was deleted.

2 changes: 1 addition & 1 deletion bin/root/tools/resx.js

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

2 changes: 1 addition & 1 deletion bin/root/tools/setFormCustomizable.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hso/d365-cli",
"version": "2.1.1",
"version": "2.2.0",
"author": "HSO Innovation <[email protected]> (http://www.hso.com)",
"description": "HSO D365 Command Line Interface",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions src/Update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class Update {
console.log(`Updating D365 Project...`);
const variables = await Variables.get();
Update.updateWebresources();
Update.updateToolsFolder();
Update.updateSrcFolder();
Update.updateProjectRootFolder();
Update.updatePackageJson(variables);
Expand Down Expand Up @@ -64,6 +65,12 @@ export class Update {
});
}

private static updateToolsFolder(): void {
console.log('Updating tools folder...');
shell.rm('-rf', `tools/deploy.js`);
shell.exec('git rm tools/deploy.js');
}

private static updateSrcFolder(): void {
if (shell.ls(['./tsconfig.json']).length !== 1) {
console.log(`Remove src/tsconfig.json...`);
Expand Down
19 changes: 5 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Create} from './Create';
import {Update} from './update';
import {Generator} from './generator/Generator';
import {Variables} from './Variables';
import {Deploy} from './root/tools/Deploy';

program
.version('1.8.0') // .version(require('../package').version)
Expand Down Expand Up @@ -86,24 +87,14 @@ program

program
.command('deploy')
.alias('d')
.option('-f, --force', 'Force unmodified files as well')
.description('Invokes the deploy builder')
.action(() => {
shell.exec('npm run deploy');
})
.on('--help', () => {
.action(({force}) => {
Deploy.deployProject(force);
}).on('--help', () => {
console.log(`Distributes the project to the D365 environment. You need to run the 'build' command first`);
});

/* easy debugging/programming
program
.command('deploy')
.description('Invokes the deploy builder')
.action(() => {
console.log(Deploy);
});
*/

program
.command('update')
.alias('u')
Expand Down
19 changes: 17 additions & 2 deletions src/root/tools/Deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {AdalRouter} from './AdalRouter';
import * as crypto from 'crypto';
import * as xml2js from 'xml2js';
import * as shell from 'shelljs';
import * as colors from 'colors';

interface LibraryItem {
name: string;
Expand All @@ -28,7 +29,21 @@ interface XmlDoc {
}

export class Deploy extends AdalRouter {
public static async deployProject(force: boolean): Promise<void> {
if (process.argv[4]) {
console.log(colors.red(`No spaces allowed after update command!`));
} else {
new Deploy(force);
}
}

private md5 = (contents: string): string => crypto.createHash('md5').update(contents).digest('hex');
private force: boolean;

constructor(force: boolean) {
super();
this.force = force;
}

protected onAuthenticated(): Promise<void> {
return this.deploy();
Expand Down Expand Up @@ -78,7 +93,7 @@ export class Deploy extends AdalRouter {
base64 = data.toString('base64'),
dependencyXML = await this.generateDependencyXML(filepath, webresource, data),
md5New = this.md5(base64);
if (md5Orig !== md5New || dependencyXML && dependencyXML !== webresource?.dependencyxml) {
if (this.force || md5Orig !== md5New || dependencyXML && dependencyXML !== webresource?.dependencyxml) {
webresource.content = base64;
webresource.dependencyxml = dependencyXML;
try {
Expand Down Expand Up @@ -257,4 +272,4 @@ export class Deploy extends AdalRouter {
});
}
}
new Deploy();
// new Deploy();
3 changes: 0 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ module.exports = {
},
externals: [nodeExternals()],
entry: {
"root/tools/deploy": [
path.resolve(__dirname, "src/root/tools/Deploy.ts")
],
"root/tools/resx": [
path.resolve(__dirname, "src/root/tools/Resx.ts")
],
Expand Down

0 comments on commit 2ff5a4a

Please sign in to comment.