Skip to content

feat: add MLE application template #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,8 @@ updates:
- "templates-ords-remix"
commit-message:
prefix: fix(deps)

- package-ecosystem: "npm"
directory: "/templates/mle-js-basic/"
schedule:
interval: "monthly"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The package offers the following templates, some of them connect to the database
- `node-angular`: A starter template that uses Node.js and [Angular](https://angular.dev/). It is built by [Angular CLI](https://github.com/angular/angular-cli). (New in `v1.2.0`)
- `node-react-todo`: A simple task manager template that uses Node.js and [React](https://react.dev/). It demonstrates the use of the database for Create, Read, Update and Delete (CRUD) operations. It is built by [vite](https://vitejs.dev/).
- `ords-remix-jwt-sample`: A full stack Concert Application made with [Remix](https://remix.run/) that showcases the [Oracle REST Data Services](https://www.oracle.com/database/technologies/appdev/rest.html) functionalities. Some extra configuration is required, learn more about it in the `ords-remix-jwt-sample` [Getting Started Guide](/templates/ords-remix-jwt-sample/README.md#getting-started).
- `mle-js-basic`: A starter template application that demonstrates how backend applications can be developed using [Oracle Database Multilingual Engine (MLE)](https://docs.oracle.com/en/database/oracle/oracle-database/23/mlejs/introduction-to-mle.html). Requires SQLcl to be installed, for more information please read [README](/templates/mle-js-basic/README.md)

Each of the templates include documentation for you to get started with them, as well as NPM scripts for you to use right after generating the application.

Expand Down
16 changes: 15 additions & 1 deletion generators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ export default class extends Generator {
this.templatePath( `${this.options.templateChoice}/.env.example` ),
this.destinationPath( '.env.example' ),
);
} else if (this.options.templateChoice.includes('mle-js-basic' )) {
if( 'walletPath' in this.options ) {
this.fs.copyTpl(
this.templatePath( `${this.options.templateChoice}/.env.example.wallet` ),
this.destinationPath( '.env' ),
this.options
);
} else {
this.fs.copyTpl(
this.templatePath( `${this.options.templateChoice}/.env.example` ),
this.destinationPath( '.env' ),
this.options
);
}
} else {
this.fs.copyTpl(
this.templatePath( `${ path.dirname( this.options.templateChoice ) }/app/${ path.basename( this.options.templateChoice ) == 'node-jet' ? 'index-proxied' : 'index' }.cjs` ),
Expand Down Expand Up @@ -169,7 +183,7 @@ export default class extends Generator {
connectionString: '',
connectionUsername: '',
walletPassword: '',
walletPath: '',
walletPath: ''
}
);
this.fs.copyTpl(
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@
"overrides": {
"whatwg-url": "^14.1.0"
}
}
}
22 changes: 21 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default class Generate extends Command {
'template': Flags.string({
char: 't',
description: 'Template to use',
options: ['node-vanilla', 'node-react', 'node-vue', 'node-react-todo', 'node-jet', 'node-angular', 'ords-remix-jwt-sample'],
options: ['node-vanilla', 'node-react', 'node-vue', 'node-react-todo', 'node-jet', 'node-angular', 'ords-remix-jwt-sample', 'mle-js-basic'],
multiple: false
}),

Expand Down Expand Up @@ -313,6 +313,7 @@ export default class Generate extends Command {
const databaseSID = flags['db-sid'] ?? '';
const databaseServiceName = flags['db-service-name'] ?? '';
const databaseUsername = flags['db-username'] ?? '';
const sqlclPath = flags['sql-cl'] ?? '';

// TODO: Validate and use wallet path
const walletPathDirectory = flags['wallet-path'] ? flags['wallet-path'] : '';
Expand Down Expand Up @@ -373,6 +374,11 @@ export default class Generate extends Command {
value: 'ords-remix-jwt-sample',
description: 'This creates a fullstack Concert Application made with Remix that leverages the Oracle REST Data Services functionalities. You will need to configurate the application yourself following the getting started guide.',
},
{
name: 'mle-js-basic',
value: 'mle-js-basic',
description: 'This creates an empty project with MLE and Oracle database connection starter code.'
},
],
default: 'node-vanilla'
},
Expand Down Expand Up @@ -533,6 +539,20 @@ export default class Generate extends Command {
} );
}

if(templateChoice == 'mle-js-basic'){
// Ask the user for the path to SQLcl
Object.assign( configObject, {
sqlclPath: sqlclPath === '' ? await input(
{
message: 'Please provide full path to your SQLcl installation: ',
validate ( input ) {
return input.trim().length === 0 ? 'This field cannot be empty!' : true;
}
},
) : sqlclPath
});
}

generateDatabaseApp( configObject );
// TODO: This is the object that holds the application name, template choice, connection details depending on the chosen connection type.
// console.log( JSON.stringify( configObject, null, ' ' ) );
Expand Down
2 changes: 1 addition & 1 deletion templates/app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ CONNECT_STRING=<%= connectionString %>

# Optional HTTP Proxy Settings
# HTTPS_PROXY=
# HTTPS_PROXY_PORT=
# HTTPS_PROXY_PORT=
2 changes: 1 addition & 1 deletion templates/app/.env.example.basic
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ CONNECT_STRING=<%= connectionString %>

# Optional HTTP Proxy Settings
# HTTPS_PROXY=
# HTTPS_PROXY_PORT=
# HTTPS_PROXY_PORT=
15 changes: 15 additions & 0 deletions templates/mle-js-basic/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Database User
DB_USER=<%= connectionUsername %>
# Database User Password
DB_PASSWORD=<%= connectionPassword %>
# Connection string to your Autonomous Database/
# Oracle Database Free instance
CONNECT_STRING=<%= connectionString %>
MLE_MODULE=
# Optional HTTP Proxy Settings
# HTTPS_PROXY=
# HTTPS_PROXY_PORT=

# Path to your local SQL Developer Command Line
# installation
SQL_CL_PATH=<%= sqlclPath %>
18 changes: 18 additions & 0 deletions templates/mle-js-basic/.env.example.wallet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Path to database wallet
WALLET_PATH=<%= walletPath %>

# Database User
DB_USER=<%= connectionUsername %>
# Database User Password
DB_PASSWORD=<%= connectionPassword %>
# Connection string to your Autonomous Database/
# Oracle Database Free instance
CONNECT_STRING=<%= connectionString %>
MLE_MODULE=
# Optional HTTP Proxy Settings
# HTTPS_PROXY=
# HTTPS_PROXY_PORT=

# Path to your local SQL Developer Command Line
# installation
SQL_CL_PATH=<%= sqlclPath %>
22 changes: 22 additions & 0 deletions templates/mle-js-basic/.gitignore.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.DS_Store

/.env
/.env.*
!/.env.example
!/.env.*.example
/server/utils/db/wallet
Loading