Skip to content

Commit e1bd4c0

Browse files
Merge pull request #257 from DimaNike/mleapp-255
feat: add MLE application template
2 parents c3a3b44 + fee1202 commit e1bd4c0

20 files changed

+1082
-6
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,11 @@ updates:
188188
- "templates-ords-remix"
189189
commit-message:
190190
prefix: fix(deps)
191+
192+
- package-ecosystem: "npm"
193+
directory: "/templates/mle-ts-sample/"
194+
schedule:
195+
interval: "monthly"
196+
labels:
197+
- "dependencies"
198+
- "templates-mle"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The package offers the following templates, some of them connect to the database
5858
- `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`)
5959
- `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/).
6060
- `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).
61+
- `mle-ts-sample`: 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-ts-sample/README.md)
6162

6263
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.
6364

generators/index.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ export default class extends Generator {
142142
this.templatePath( `${this.options.templateChoice}/.env.example` ),
143143
this.destinationPath( '.env.example' ),
144144
);
145+
} else if (this.options.templateChoice.includes('mle-ts-sample')) {
146+
if( 'walletPath' in this.options ) {
147+
this.fs.copyTpl(
148+
this.templatePath( `${this.options.templateChoice}/.env.example.wallet` ),
149+
this.destinationPath( '.env' ),
150+
this.options
151+
);
152+
} else {
153+
this.fs.copyTpl(
154+
this.templatePath( `${this.options.templateChoice}/.env.example` ),
155+
this.destinationPath( '.env' ),
156+
this.options
157+
);
158+
}
145159
} else {
146160
this.fs.copyTpl(
147161
this.templatePath( `${ path.dirname( this.options.templateChoice ) }/app/${ path.basename( this.options.templateChoice ) == 'node-jet' ? 'index-proxied' : 'index' }.cjs` ),
@@ -169,7 +183,7 @@ export default class extends Generator {
169183
connectionString: '',
170184
connectionUsername: '',
171185
walletPassword: '',
172-
walletPath: '',
186+
walletPath: ''
173187
}
174188
);
175189
this.fs.copyTpl(

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@
111111
"overrides": {
112112
"whatwg-url": "^14.2.0"
113113
}
114-
}
114+
}

src/index.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default class Generate extends Command {
207207
'template': Flags.string({
208208
char: 't',
209209
description: 'Template to use',
210-
options: ['node-vanilla', 'node-react', 'node-vue', 'node-react-todo', 'node-jet', 'node-angular', 'ords-remix-jwt-sample'],
210+
options: ['node-vanilla', 'node-react', 'node-vue', 'node-react-todo', 'node-jet', 'node-angular', 'ords-remix-jwt-sample', 'mle-ts-sample'],
211211
multiple: false
212212
}),
213213

@@ -313,6 +313,7 @@ export default class Generate extends Command {
313313
const databaseSID = flags['db-sid'] ?? '';
314314
const databaseServiceName = flags['db-service-name'] ?? '';
315315
const databaseUsername = flags['db-username'] ?? '';
316+
const sqlclPath = flags['sqlcl'] ?? '';
316317

317318
// TODO: Validate and use wallet path
318319
const walletPathDirectory = flags['wallet-path'] ? flags['wallet-path'] : '';
@@ -373,7 +374,13 @@ export default class Generate extends Command {
373374
value: 'ords-remix-jwt-sample',
374375
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.',
375376
},
377+
{
378+
name: 'mle-ts-sample',
379+
value: 'mle-ts-sample',
380+
description: 'This creates an empty project with MLE and Oracle database connection starter code.'
381+
},
376382
],
383+
pageSize: 10,
377384
default: 'node-vanilla'
378385
},
379386
) : template;
@@ -533,6 +540,20 @@ export default class Generate extends Command {
533540
} );
534541
}
535542

543+
if(templateChoice == 'mle-ts-sample'){
544+
// Ask the user for the path to SQLcl
545+
Object.assign( configObject, {
546+
sqlclPath: sqlclPath === '' ? await input(
547+
{
548+
message: 'Please provide full path to your SQLcl installation (SQLcl can be downloaded and installed from https://www.oracle.com/database/sqldeveloper/technologies/sqlcl): ',
549+
validate ( input ) {
550+
return input.trim().length === 0 ? 'This field cannot be empty!' : true;
551+
}
552+
},
553+
) : sqlclPath
554+
});
555+
}
556+
536557
generateDatabaseApp( configObject );
537558
// TODO: This is the object that holds the application name, template choice, connection details depending on the chosen connection type.
538559
// console.log( JSON.stringify( configObject, null, ' ' ) );

templates/app/.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ CONNECT_STRING=<%= connectionString %>
1111

1212
# Optional HTTP Proxy Settings
1313
# HTTPS_PROXY=
14-
# HTTPS_PROXY_PORT=
14+
# HTTPS_PROXY_PORT=

templates/app/.env.example.basic

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ CONNECT_STRING=<%= connectionString %>
77

88
# Optional HTTP Proxy Settings
99
# HTTPS_PROXY=
10-
# HTTPS_PROXY_PORT=
10+
# HTTPS_PROXY_PORT=

templates/mle-ts-sample/.env.example

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Database User
2+
DB_USER=<%= connectionUsername %>
3+
# Database User Password
4+
DB_PASSWORD=<%= connectionPassword %>
5+
# Connection string to your Autonomous Database/
6+
# Oracle Database instance
7+
CONNECT_STRING=<%= connectionString %>
8+
# Oracle MLE Module name
9+
MLE_MODULE=
10+
# Optional HTTP Proxy Settings
11+
# HTTPS_PROXY=
12+
# HTTPS_PROXY_PORT=
13+
14+
# Path to your local SQL Developer Command Line
15+
# installation
16+
SQL_CL_PATH=<%= sqlclPath %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Path to database wallet
2+
WALLET_PATH=<%= walletPath %>
3+
4+
# Database User
5+
DB_USER=<%= connectionUsername %>
6+
# Database User Password
7+
DB_PASSWORD=<%= connectionPassword %>
8+
# Connection string to your Autonomous Database/
9+
# Oracle Database instance
10+
CONNECT_STRING=<%= connectionString %>
11+
# Oracle MLE Module name
12+
MLE_MODULE=
13+
# Optional HTTP Proxy Settings
14+
# HTTPS_PROXY=
15+
# HTTPS_PROXY_PORT=
16+
17+
# Path to your local SQL Developer Command Line
18+
# installation
19+
SQL_CL_PATH=<%= sqlclPath %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.DS_Store
17+
18+
/.env
19+
/.env.*
20+
!/.env.example
21+
!/.env.*.example
22+
/server/utils/db/wallet

0 commit comments

Comments
 (0)