Skip to content

Commit

Permalink
refactor: reorganize common parameters and scripts into utility_scrip…
Browse files Browse the repository at this point in the history
…ts module
  • Loading branch information
sharjeelyunus committed Dec 31, 2024
1 parent 6805eef commit 0d94acb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion starter/src/dart_runner.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { exec } from 'child_process';
import { commonParameters } from './modules';
import { ArgumentParseResult, Script } from './interfaces';
import {
checkAndAskForMissingArgs,
findScript,
logError,
selectModules,
} from './utils';
import { commonParameters } from './utility_scripts';

const parseArguments = (args: string[]): ArgumentParseResult => {
const scripts: string[] = [];
Expand Down
47 changes: 1 addition & 46 deletions starter/src/modules.ts → starter/src/modules_scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,7 @@ import {
firebaseIOSParameters,
firebaseWebParameters,
} from './common-params';
import { Parameter, Script } from './interfaces';

// Common parameters available across scripts and modules
export const commonParameters: Parameter[] = [
{
key: 'platform',
question: 'Which platform(s) are you targeting?',
type: 'select',
choices: ['ios', 'android', 'web'],
platform: ['android', 'ios', 'web'],
},
{
key: 'ensemble_version',
question: 'Which version of ensemble are you using?',
type: 'text',
platform: ['android', 'ios', 'web'],
},
];
import { Script } from './interfaces';

// Modules (called with `enable` command)
export const modules: Script[] = [
Expand Down Expand Up @@ -299,31 +282,3 @@ export const modules: Script[] = [
],
},
];

// Custom Scripts (standalone Dart scripts)
export const scripts: Script[] = [
{
name: 'generateKeystore',
path: 'scripts/generate_keystore.dart',
parameters: [
{
key: 'storePassword',
question: 'Please provide the store password: ',
platform: ['android'],
type: 'text',
},
{
key: 'keyPassword',
question: 'Please provide the key password: ',
platform: ['android'],
type: 'text',
},
{
key: 'keyAlias',
question: 'Please provide the key alias: ',
platform: ['android'],
type: 'text',
},
],
},
];
46 changes: 46 additions & 0 deletions starter/src/utility_scripts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Parameter, Script } from './interfaces';

// Common parameters available across scripts and modules
export const commonParameters: Parameter[] = [
{
key: 'platform',
question: 'Which platform(s) are you targeting?',
type: 'select',
choices: ['ios', 'android', 'web'],
platform: ['android', 'ios', 'web'],
},
{
key: 'ensemble_version',
question: 'Which version of ensemble are you using?',
type: 'text',
platform: ['android', 'ios', 'web'],
},
];

// Custom Scripts (standalone Dart scripts)
export const scripts: Script[] = [
{
name: 'generateKeystore',
path: 'scripts/generate_keystore.dart',
parameters: [
{
key: 'storePassword',
question: 'Please provide the store password: ',
platform: ['android'],
type: 'text',
},
{
key: 'keyPassword',
question: 'Please provide the key password: ',
platform: ['android'],
type: 'text',
},
{
key: 'keyAlias',
question: 'Please provide the key alias: ',
platform: ['android'],
type: 'text',
},
],
},
];
3 changes: 2 additions & 1 deletion starter/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import prompts from 'prompts';
import { Parameter, Platform, Script } from './interfaces';
import { commonParameters, modules, scripts } from './modules';
import { commonParameters, scripts } from './utility_scripts';
import { modules } from './modules_scripts';

export const findScript = (name: string): Script => {
const script =
Expand Down

0 comments on commit 0d94acb

Please sign in to comment.