Skip to content

Commit

Permalink
Merge branch 'release/5.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Feb 15, 2022
2 parents fafa95d + 4de14e5 commit c6010d2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/main.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion bin/root/crm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"adal": {
"clientId": "3d14ef79-de44-4358-bb18-75b54d1c4e4e",
"redirectUri": "http://localhost:3000/auth"
}
},
"version": "<%= version %>"
}
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": "5.11.4",
"version": "5.12.0",
"author": "HSO Innovation <[email protected]> (https://www.hso.com)",
"description": "Dynamics 365 Command Line Interface for TypeScript projects for Dataverse",
"repository": {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/Create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export class Create {
shell.sed('-i', new RegExp('<%= publisher_prefix %>', 'ig'), answers.publisher_prefix, crmJsonFile);
shell.sed('-i', new RegExp('<%= environment %>', 'ig'), answers.environment, crmJsonFile);
shell.sed('-i', new RegExp('<%= namespace %>', 'ig'), answers.namespace, crmJsonFile);
const version = shell.exec('hso-d365 --version').stdout.replace(/\n/ig, '');
shell.sed('-i', new RegExp('<%= version %>', 'ig'), version, crmJsonFile);
}

private static initWebresourcesCrmJson(answers: CreateAnswers): void {
Expand Down
4 changes: 3 additions & 1 deletion src/commands/Update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class Update {
shell.sed('-i', new RegExp('<%= publisher %>', 'ig'), crmSettings.crm.publisher_prefix, '../crm.json');
shell.sed('-i', new RegExp('<%= environment %>', 'ig'), crmSettings.crm.url, '../crm.json');
shell.sed('-i', new RegExp('<%= namespace %>', 'ig'), (crmSettings as unknown as {webresource: {namespace:string} }).webresource.namespace, '../crm.json');
shell.exec('git add ../crm.json');

// Webresources/crm.json
const webresourcesSettings: WebresourcesCrmJson = JSON.parse(fs.readFileSync('./tools/crm.json', 'utf8'));
Expand All @@ -127,6 +126,9 @@ export class Update {
shell.rm('-rf', `./tools`);
shell.exec('git rm ./tools');
}
const version = shell.exec('hso-d365 --version').stdout.replace(/\n/ig, '');
shell.sed('-i', new RegExp('<%= version %>', 'ig'), version, '../crm.json');
shell.exec('git add ../crm.json');
}

private static updatePackageJson(): void {
Expand Down
20 changes: 17 additions & 3 deletions src/commands/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import {PCF} from './PCF';
import {CrmJson} from '../root/CrmJson';
import fs from 'fs';

const checkVersion = (): boolean => {
const cliVersion = shell.exec('hso-d365 --version').stdout.replace(/\n/ig, '');
const crmSettings: CrmJson = JSON.parse(fs.readFileSync('../crm.json', 'utf8'));
if (cliVersion !== crmSettings.version) {
console.log(`Version mismatch!\nCLI version: ${cliVersion}\nProject version: ${crmSettings.version}.`);
console.log(`Please update project or cli first.`);
return false;
}
return true;
};

program
.version(packageJson.version)
.usage('<command> [options]');
Expand All @@ -36,20 +47,23 @@ program
.alias('rg')
.description('Regenerates files')
.action(async () => {
await RegeneratorRouter.regenerate();
if (checkVersion()) {
await RegeneratorRouter.regenerate();
}
})
.on('--help', () => {
console.log(`Regenerates files`);
});


program
.command('generate <schematic> [name]')
.alias('g')
.option('-s, --skipForms', 'Skip generating form files')
.description('Generates and/or modifies files bases on a schematic.')
.action((schematic: string, name: string, options) => {
Generator.generate(schematic, name, options);
if (checkVersion()) {
Generator.generate(schematic, name, options);
}
})
.on('--help', () => {
Generator.showGenerateHelp();
Expand Down
1 change: 1 addition & 0 deletions src/root/CrmJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface CrmJson {
redirectUri: string;
tenant: string;
};
version: string;
}

0 comments on commit c6010d2

Please sign in to comment.