Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Refactore create/override for cli to support typescript #78

Open
wants to merge 2 commits into
base: master
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
3 changes: 2 additions & 1 deletion build-packages/scandipwa-cli/actions/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { ResourceType } = require('@scandipwa/scandipwa-development-toolkit-core'
const creator = require('./lib/creator');
const componentOptions = require('./lib/options/withComponentOptions');
const storeOptions = require('./lib/options/withStoreOptions');
const queryOptions = require('./lib/options/withQueryOptions');
const withTargetDirectory = require('../../common/options/withTargetDirectory');

module.exports = (yargs) => {
Expand Down Expand Up @@ -32,7 +33,7 @@ module.exports = (yargs) => {
yargs.command(
'query <name>',
'Create a query',
(yargs) => withTargetDirectory(yargs),
(yargs) => queryOptions(withTargetDirectory(yargs)),
creator(ResourceType.Query)
);
});
Expand Down
4 changes: 3 additions & 1 deletion build-packages/scandipwa-cli/actions/create/lib/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const creator = (resourceType) => async ({
name,
container = false,
redux = false,
typescript = false,
dispatcherType,
targetModule
}) => {
Expand All @@ -28,7 +29,8 @@ const creator = (resourceType) => async ({
logic: container,
state: redux
},
dispatcherType: dispatcherTypeMap[dispatcherType]
dispatcherType: dispatcherTypeMap[dispatcherType],
isTypescript: typescript,
},
resolvedTargetModule,
logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const withComponentOptions = (yargs) => yargs
alias: 'r',
type: 'boolean',
default: false
})
.option('typescript', {
describe: 'Should component be creates as TypeScript file',
alias: 'ts',
type: 'boolean'
});

module.exports = withComponentOptions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const withQueryOptions = (yargs) => yargs
.option('typescript', {
describe: 'Should component be creates as TypeScript file',
alias: 'ts',
type: 'boolean'
});

module.exports = withQueryOptions;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const withStoreOptions = (yargs) => yargs
alias: 'd',
choices: ['query', 'regular', 'no'],
default: 'no'
})
.option('typescript', {
describe: 'Should component be creates as TypeScript file',
alias: 'ts',
type: 'boolean'
});

module.exports = withStoreOptions;
Loading