MCPcopy
hub / github.com/midrender/revideo / run

Function run

packages/create/index.js:83–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81];
82
83async function run() {
84 const options = minimist(process.argv.slice(2));
85
86 const templateFlag = Object.keys(options).find(key =>
87 templates.some(template => template.value === key),
88 );
89
90 const pathResponse = await prompts([
91 // Prompt for project name
92 {
93 type: 'text',
94 name: 'name',
95 message: 'Project name',
96 initial: 'my-revideo-project',
97 validate: value =>
98 isValidPackageName(value)
99 ? true
100 : 'Project name must be a valid npm package name.',
101 },
102 // Prompt for project path
103 {
104 type: 'text',
105 name: 'path',
106 message: 'Project path',
107
108 initial: value => {
109 return path.normalize(value.replace('@', ''));
110 },
111
112 validate: value => {
113 let dir = path.normalize(value.trim());
114 if (!fs.existsSync(dir)) {
115 return true;
116 }
117 if (!fs.lstatSync(dir).isDirectory()) {
118 return `Project path "${dir}" must be a valid directory.`;
119 }
120 if (fs.readdirSync(dir).length > 0) {
121 return dir === '.'
122 ? 'Current directory must be empty.'
123 : `Target directory "${dir}" must be empty.`;
124 }
125 return true;
126 },
127 format: value => path.resolve(value),
128 },
129 ]);
130
131 console.log(); // linebreak for better readability
132
133 let templateResponse;
134 if (templateFlag) {
135 templateResponse = {starter: templateFlag};
136 } else {
137 // Prompt for which example to scaffold
138 templateResponse = await prompts([
139 {
140 type: 'select',

Callers 1

index.jsFile · 0.70

Calls 8

sendEventFunction · 0.90
isValidPackageNameFunction · 0.85
copyDirectoryFunction · 0.85
getPackageManagerFunction · 0.85
getTemplateFunction · 0.85
replaceMethod · 0.80
logMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected