mirror of
https://github.com/strapi/strapi.git
synced 2025-11-17 10:38:30 +00:00
Add events to improve installation process
Signed-off-by: Aurélien Georget <aurelsicoko@gmail.com>
This commit is contained in:
parent
9d8944ebfe
commit
bc9ba3d2a7
@ -12,10 +12,7 @@ const { trackUsage, captureStderr } = require('./utils/usage');
|
|||||||
const packageJSON = require('./resources/json/package.json');
|
const packageJSON = require('./resources/json/package.json');
|
||||||
const databaseJSON = require('./resources/json/database.json.js');
|
const databaseJSON = require('./resources/json/database.json.js');
|
||||||
|
|
||||||
module.exports = async function createProject(
|
module.exports = async function createProject(scope, { connection, dependencies }) {
|
||||||
scope,
|
|
||||||
{ connection, dependencies }
|
|
||||||
) {
|
|
||||||
console.log('Creating files.');
|
console.log('Creating files.');
|
||||||
|
|
||||||
const { rootPath } = scope;
|
const { rootPath } = scope;
|
||||||
@ -29,13 +26,12 @@ module.exports = async function createProject(
|
|||||||
const dotFiles = await fse.readdir(join(resources, 'dot-files'));
|
const dotFiles = await fse.readdir(join(resources, 'dot-files'));
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
dotFiles.map(name => {
|
dotFiles.map(name => {
|
||||||
return fse.copy(
|
return fse.copy(join(resources, 'dot-files', name), join(rootPath, `.${name}`));
|
||||||
join(resources, 'dot-files', name),
|
|
||||||
join(rootPath, `.${name}`)
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await trackUsage({ event: 'didCopyProjectFiles', scope });
|
||||||
|
|
||||||
// copy templates
|
// copy templates
|
||||||
await fse.writeJSON(
|
await fse.writeJSON(
|
||||||
join(rootPath, 'package.json'),
|
join(rootPath, 'package.json'),
|
||||||
@ -51,6 +47,8 @@ module.exports = async function createProject(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await trackUsage({ event: 'didWritePackageJSON', scope });
|
||||||
|
|
||||||
// ensure node_modules is created
|
// ensure node_modules is created
|
||||||
await fse.ensureDir(join(rootPath, 'node_modules'));
|
await fse.ensureDir(join(rootPath, 'node_modules'));
|
||||||
|
|
||||||
@ -66,11 +64,15 @@ module.exports = async function createProject(
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await trackUsage({ event: 'didCopyConfigurationFiles', scope });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await fse.remove(scope.rootPath);
|
await fse.remove(scope.rootPath);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await trackUsage({ event: 'willInstallProjectDependencies', scope });
|
||||||
|
|
||||||
const installPrefix = chalk.yellow('Installing dependencies:');
|
const installPrefix = chalk.yellow('Installing dependencies:');
|
||||||
const loader = ora(installPrefix).start();
|
const loader = ora(installPrefix).start();
|
||||||
|
|
||||||
@ -93,6 +95,8 @@ module.exports = async function createProject(
|
|||||||
|
|
||||||
loader.stop();
|
loader.stop();
|
||||||
console.log(`Dependencies installed ${chalk.green('successfully')}.`);
|
console.log(`Dependencies installed ${chalk.green('successfully')}.`);
|
||||||
|
|
||||||
|
await trackUsage({ event: 'didInstallProjectDependencies', scope });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loader.stop();
|
loader.stop();
|
||||||
await trackUsage({
|
await trackUsage({
|
||||||
@ -119,9 +123,7 @@ module.exports = async function createProject(
|
|||||||
);
|
);
|
||||||
console.log();
|
console.log();
|
||||||
console.log(
|
console.log(
|
||||||
`cd ${chalk.green(rootPath)} && ${chalk.cyan(
|
`cd ${chalk.green(rootPath)} && ${chalk.cyan(scope.useYarn ? 'yarn' : 'npm')} install`
|
||||||
scope.useYarn ? 'yarn' : 'npm'
|
|
||||||
)} install`
|
|
||||||
);
|
);
|
||||||
console.log();
|
console.log();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user