I mentioned in #9 that the absence of dynamics in the second argument causes some inconvenience.
Current situation
Currently i can't create new folder with variable name.
cliOf('Create module',module).ask({name: 'moduleName',message: 'How we name it?',type: 'input'}).move(answers=>(['./template']),`../src/modules/???`)And I can't understand how i can rename the newly created folder after creating it with some temporary unique name. For example:
consttempHash=Date.now();cliOf('Create module',module).ask({name: 'moduleName',message: 'How we name it?',type: 'input'}).move(answers=>(['./template']),`../src/modules/${tempHash}`).rename(`../src/modules/${tempHash}`,(answers)=>{// how I can rename folder, instead file name?})Workaround (work only for unix systems ⚠️ ):
.call(async({ moduleName })=>{awaitchildProcess.spawn(`cp -r ./generators/module ./k2-packages/${moduleName}/`);})Proposed api:
I think a simpler api that will cover most of the use cases will look something like this
Just copy with renaming:
cliOf('Create module',module).copy('./templates/module/index.ts','./src/NewModule/main.ts')/* result:ls ./src/NewModule/ ⇐ (NewModule folder is being created if not exist before that)main.ts*/Copy by mask:
cliOf('Create module',module).copy('./templates/module/*.ts','./src/NewModule/')/* result:ls ./src/NewModule/index.tsutils.tssome.ts*/Copy files using answers (in both arguments):
cliOf('Create module',module).ask({name: 'type',message: 'What type of it?',type: 'input'}).ask({name: 'name',message: 'How we name it?',type: 'input'}).copy(answers=>([`./templates/${answers.type}/*.ts`,`./src/${answers.name}/`))/* result:ls ./src/myAwesomeModule/index.tsutils.tssome.ts*/Copy in place (Optional - just for consistent)
cliOf('Clone module',module).copy(`./src/module/`)/* ls ./src/module_copy/ index.ts utils.ts some.ts*/.copy(`./src/module/*`)/* ls ./src/module/ index.ts index_copy.ts utils.ts utils_copy.ts some.ts some_copy.ts*/.copy(`./src/module/some.ts*`)/* ls ./src/module/ index.ts index_copy.ts utils.ts utils_copy.ts some.ts some_copy.ts some_copy_copy.ts*/
I mentioned in #9 that the absence of dynamics in the second argument causes some inconvenience.
Current situation
Currently i can't create new folder with variable name.
And I can't understand how i can rename the newly created folder after creating it with some temporary unique name. For example:
Workaround (work only for unix systems⚠️ ):
Proposed api:
I think a simpler api that will cover most of the use cases will look something like this
Just copy with renaming:
Copy by mask:
Copy files using answers (in both arguments):
Copy in place (Optional - just for consistent)