Skip to content

Commit

Permalink
Upgraded to Yeoman 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Yong Sheng Tan committed Dec 13, 2023
1 parent e084f1e commit 4b90fc6
Show file tree
Hide file tree
Showing 23 changed files with 1,682 additions and 2,669 deletions.
51 changes: 0 additions & 51 deletions .github/ISSUE_TEMPLATE/MEETING_MINUTES.md

This file was deleted.

4 changes: 4 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"timeout": 0,
"recursive": true
}
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,6 @@ In case of a Java bot application, once the project is generated, the generator

_NOTE:_ The generation process will continue no matter what the build status is.

## Known issues

If you are using node 16.0.0 and encounter the following error when trying to run `yo @finos/symphony` or `yo @finos/symphony 2.0`:
```
/usr/local/lib/node_modules/yo/node_modules/editions/edition-es5/index.js:317
throw util_js_1.errtion(
^
Error: editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening.
at new Errlop (/usr/local/lib/node_modules/yo/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/usr/local/lib/node_modules/yo/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/usr/local/lib/node_modules/yo/node_modules/editions/edition-es5/index.js:317:21)
at solicitEdition (/usr/local/lib/node_modules/yo/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/usr/local/lib/node_modules/yo/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/usr/local/lib/node_modules/yo/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Function.Module._load (node:internal/modules/cjs/loader:828:14)
↳ Error: editions-autoloader-none-suitable: Unable to determine a suitable edition, as none were suitable.
...
```
then please try to downgrade to node 15 or node 14 (seems to be linked with
https://github.com/electron-userland/electron-builder/issues/5668).

## Contributing

1. Fork it (<https://github.com/finos/generator-symphony/fork>)
Expand Down
193 changes: 98 additions & 95 deletions generators/_lib/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const forge = require('node-forge');
const axios = require('axios');
import forge from 'node-forge'
import axios from 'axios'

const JAVA_BDK_VERSION_DEFAULT = '2.14.3'
const PYTHON_BDK_VERSION_DEFAULT = '2.7.0'
Expand All @@ -9,96 +9,99 @@ const ADK_VERSION_DEFAULT = '1.3.0'

const timeout = { timeout: 5000 }

module.exports = {
/**
* Return a RSA key pair in PEM format.
*
* @param size the size for the private key in bits.
* @returns {{private, public}} private and public key content in PEM format.
*/
keyPair: (size) => {
let generated = forge.pki.rsa.generateKeyPair(size || 4096);
return {
private: forge.pki.privateKeyToPem(generated.privateKey),
public: forge.pki.publicKeyToRSAPublicKeyPem(generated.publicKey)
};
},
/**
* Gets the latest Java BDK version from maven central
*
* @returns Java BDK version
*/
getJavaBdkVersion: async () => {
const uri = 'https://search.maven.org/solrsearch/select?q=g:org.finos.symphony.bdk+AND+a:symphony-bdk-bom&core=gav'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response || response['response']['docs'].length === 0) {
console.log('Failed to fetch latest Java BDK version from Maven Central')
return JAVA_BDK_VERSION_DEFAULT;
} else {
return response['response']['docs'].filter(d => !d.id.match(/(RC|alpha)/g))[0].v;
}
},
/**
* Gets the latest Python BDK version from PyPi
*
* @returns Python BDK version
*/
getPythonBdkVersion: async () => {
const uri = 'https://pypi.org/pypi/symphony-bdk-python/json'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response) {
console.log('Failed to fetch latest Python BDK version from PyPi')
return PYTHON_BDK_VERSION_DEFAULT;
} else {
return response['info']['version'];
}
},
/**
* Gets the latest WDK version from maven central
*
* @returns WDK version
*/
getWdkVersion: async () => {
const uri = 'https://search.maven.org/solrsearch/select?q=g:org.finos.symphony.wdk+AND+a:workflow-bot-app&core=gav&rows=10'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response || response['response']['docs'].length === 0) {
console.log('Failed to fetch latest WDK version from Maven Central')
return WDK_VERSION_DEFAULT;
} else {
return response['response']['docs'].filter(d => !d.v.match(/-pre/g))[0].v;
}
},
/**
* Gets the latest ADK version from NPM
*
* @returns ADK version
*/
getAdkVersion: async () => {
const uri = 'https://registry.npmjs.org/@symphony-ui/adk';
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response) {
console.log('Failed to fetch latest ADK version from NPM')
return ADK_VERSION_DEFAULT;
} else {
return response['dist-tags']?.latest;
}
},
/**
* Gets the default Spring version
*
* @returns Default Spring version
*/
getSpringVersion: () => SPRING_VERSION_DEFAULT,
};
/**
* Return a RSA key pair in PEM format.
*
* @param size the size for the private key in bits.
* @returns {{private, public}} private and public key content in PEM format.
*/
export const keyPair = (size) => {
let generated = forge.pki.rsa.generateKeyPair(size || 4096);
return {
private: forge.pki.privateKeyToPem(generated.privateKey),
public: forge.pki.publicKeyToRSAPublicKeyPem(generated.publicKey)
};
}

/**
* Gets the latest Java BDK version from maven central
*
* @returns Java BDK version
*/
export const getJavaBdkVersion = async () => {
const uri = 'https://search.maven.org/solrsearch/select?q=g:org.finos.symphony.bdk+AND+a:symphony-bdk-bom&core=gav'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response || response['response']['docs'].length === 0) {
console.log('Failed to fetch latest Java BDK version from Maven Central')
return JAVA_BDK_VERSION_DEFAULT;
} else {
return response['response']['docs'].filter(d => !d.id.match(/(RC|alpha)/g))[0].v;
}
}

/**
* Gets the latest Python BDK version from PyPi
*
* @returns Python BDK version
*/
export const getPythonBdkVersion = async () => {
const uri = 'https://pypi.org/pypi/symphony-bdk-python/json'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response) {
console.log('Failed to fetch latest Python BDK version from PyPi')
return PYTHON_BDK_VERSION_DEFAULT;
} else {
return response['info']['version'];
}
}

/**
* Gets the latest WDK version from maven central
*
* @returns WDK version
*/
export const getWdkVersion = async () => {
const uri = 'https://search.maven.org/solrsearch/select?q=g:org.finos.symphony.wdk+AND+a:workflow-bot-app&core=gav&rows=10'
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response || response['response']['docs'].length === 0) {
console.log('Failed to fetch latest WDK version from Maven Central')
return WDK_VERSION_DEFAULT;
} else {
return response['response']['docs'].filter(d => !d.v.match(/-pre/g))[0].v;
}
}

/**
* Gets the latest ADK version from NPM
*
* @returns ADK version
*/
export const getAdkVersion = async () => {
const uri = 'https://registry.npmjs.org/@symphony-ui/adk';
const response = await axios(uri, timeout).then(
(response) => response?.data,
() => null,
);
if (!response) {
console.log('Failed to fetch latest ADK version from NPM')
return ADK_VERSION_DEFAULT;
} else {
return response['dist-tags']?.latest;
}
}

/**
* Gets the default Spring version
*
* @returns Default Spring version
*/
export const getSpringVersion = () => SPRING_VERSION_DEFAULT
35 changes: 25 additions & 10 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const Generator = require('yeoman-generator')
const colors = require('colors')
const packageJson = require('../../package.json')
const fs = require('fs')
import Generator from 'yeoman-generator'
import colors from 'colors'
import fs from 'fs'
import { createRequire } from 'node:module';
import java from '../java/index.js'
import python from '../python/index.js'
import extApp from '../ext-app/index.js'
import extAppBdk from '../ext-app-bdk/index.js'
import workflow from '../workflow/index.js'

module.exports = class extends Generator {
export default class extends Generator {
constructor(args, opts) {
super(args, opts, { customInstallTask: true })
}

initializing() {
const packageJson = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url)))

this.log(` __ __ ___ _
\\ \\ / /__ / __|_ _ _ __ _ __| |_ ___ _ _ _ _
\\ V / _ \\ \\__ \\ || | ' \\| '_ \\ ' \\/ _ \\ ' \\ || |
Expand Down Expand Up @@ -109,15 +116,23 @@ module.exports = class extends Generator {
])

if (this.answers.language === 'java') {
this.composeWith(require.resolve('../java'), this.answers)
this._compose(java, '../java')
} else if (this.answers.language === 'python') {
this.composeWith(require.resolve('../python'), this.answers)
this._compose(python, '../python')
} else if (this.answers.application === 'workflow') {
this.composeWith(require.resolve('../workflow'), this.answers)
this._compose(workflow, '../workflow')
} else if (this.answers.application === 'ext-app') {
this.composeWith(require.resolve('../ext-app'), this.answers)
this._compose(extApp, '../ext-app')
} else if (this.answers.application === 'ext-app-bdk') {
this.composeWith(require.resolve('../ext-app-bdk'), this.answers)
this._compose(extAppBdk, '../ext-app-bdk')
}
}

_compose(fn, path) {
const require = createRequire(import.meta.url)
return this.composeWith({
Generator: fn,
path: require.resolve(path)
}, this.answers)
}
}
Loading

0 comments on commit 4b90fc6

Please sign in to comment.