mirror of
https://github.com/strapi/strapi.git
synced 2025-07-24 09:25:25 +00:00

Create starter CLI Add spaces option Extract project basename Add starter shortcut Refactor git init commit Replace concurrently with npm-run-all Move fetch repo function to dedicated file Allow shortcut to accept external org repo Fix package config & readme Fix versions Add task prefixes Update readme [Starter CLI] error handling (#9600) * Display error message + help for missing arguments * Add cleaner error messages * Bump commander from v6.1.0 to v7.1.0 * Capture and log errors from commander * Simplify cli argument errors * Provide more human readable error messages * Replace throw with console log * Add logger Add starter tracking Add wrapper for tracking keys Update root config Keep template in scope root fix strapi config Fix open frontend Remove open-cli Update for rename frontend->starter update description Update tracking Fix tests fix e2e tests Make sure packageJsonStrapi does not override unwanted keys & make it optional to avoid errors simplify metadata strapi Allow stater or frontend folder for smooth migration of existing starters Udpate dep Handle error
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const { execSync } = require('child_process');
|
|
const execa = require('execa');
|
|
const hasYarn = require('./has-yarn');
|
|
const logger = require('./logger');
|
|
|
|
/**
|
|
* @param {string} path Path to directory (frontend, backend)
|
|
*/
|
|
function runInstall(path) {
|
|
if (hasYarn) {
|
|
return execa('yarn', ['install'], {
|
|
cwd: path,
|
|
stdin: 'ignore',
|
|
});
|
|
}
|
|
|
|
return execa('npm', ['install'], { cwd: path, stdin: 'ignore' });
|
|
}
|
|
|
|
function runApp(rootPath) {
|
|
if (hasYarn) {
|
|
return execa('yarn', ['develop'], {
|
|
stdio: 'inherit',
|
|
cwd: rootPath,
|
|
});
|
|
} else {
|
|
return execa('npm', ['run', 'develop'], {
|
|
stdio: 'inherit',
|
|
cwd: rootPath,
|
|
});
|
|
}
|
|
}
|
|
|
|
async function initGit(rootPath) {
|
|
try {
|
|
await execa('git', ['init'], {
|
|
cwd: rootPath,
|
|
});
|
|
} catch (err) {
|
|
logger.warn(`Could not initialize a git repository`);
|
|
}
|
|
|
|
try {
|
|
await execa(`git`, [`add`, `-A`], { cwd: rootPath });
|
|
|
|
execSync(`git commit -m "Create Strapi starter project"`, {
|
|
cwd: rootPath,
|
|
});
|
|
} catch (err) {
|
|
logger.warn(`Could not create initial git commit`);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
runInstall,
|
|
runApp,
|
|
initGit,
|
|
};
|