move all scripts and commands

This commit is contained in:
Ben Irvin 2023-04-06 14:20:40 +02:00
parent 5728db43f2
commit a1be2e4c19
53 changed files with 317 additions and 158 deletions

View File

@ -33,7 +33,7 @@ jest.mock('../../index', () => {
}); });
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const createAdminCommand = require('../scripts/admin-create'); const createAdminCommand = require('../actions/admin/create-user/action');
describe('admin:create command', () => { describe('admin:create command', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -24,7 +24,7 @@ jest.mock('../../index', () => {
}); });
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const resetAdminPasswordCommand = require('../scripts/admin-reset'); const resetAdminPasswordCommand = require('../actions/admin/reset-user-password/action');
describe('admin:reset-password command', () => { describe('admin:reset-password command', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -3,7 +3,7 @@
const { yup } = require('@strapi/utils'); const { yup } = require('@strapi/utils');
const _ = require('lodash'); const _ = require('lodash');
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const strapi = require('../../index'); const strapi = require('../../../../index');
const emailValidator = yup.string().email('Invalid email address').lowercase(); const emailValidator = yup.string().email('Invalid email address').lowercase();

View File

@ -0,0 +1,15 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('admin:create-user')
.alias('admin:create')
.description('Create a new admin')
.option('-e, --email <email>', 'Email of the new admin')
.option('-p, --password <password>', 'Password of the new admin')
.option('-f, --firstname <first name>', 'First name of the new admin')
.option('-l, --lastname <last name>', 'Last name of the new admin')
.action(getLocalScript('admin/create-user'));
};

View File

@ -2,7 +2,7 @@
const _ = require('lodash'); const _ = require('lodash');
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const strapi = require('../../index'); const strapi = require('../../../../index');
const promptQuestions = [ const promptQuestions = [
{ type: 'input', name: 'email', message: 'User email?' }, { type: 'input', name: 'email', message: 'User email?' },

View File

@ -0,0 +1,13 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('admin:reset-user-password')
.alias('admin:reset-password')
.description("Reset an admin user's password")
.option('-e, --email <email>', 'The user email')
.option('-p, --password <password>', 'New password for the user')
.action(getLocalScript('admin/reset-user-password'));
};

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const strapi = require('../..'); const strapi = require('../../..');
const { buildAdmin } = require('../builders'); const { buildAdmin } = require('../../builders');
/** /**
* `$ strapi build` * `$ strapi build`

View File

@ -1,13 +1,12 @@
'use strict'; 'use strict';
const { loadProjectScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
// TODO: fix gitignore so that this folder can be called build
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi build` // `$ strapi build`
command command
.command('build') .command('build')
.option('--no-optimization', 'Build the admin app without optimizing assets') .option('--no-optimization', 'Build the admin app without optimizing assets')
.description('Build the strapi admin app') .description('Build the strapi admin app')
.action(loadProjectScript('build')); .action(getLocalScript('build-action')); // TODO: fix gitignore so that this folder can be called build
}; };

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const fs = require('fs'); const fs = require('fs');
const strapi = require('../../index'); const strapi = require('../../../../index');
const CHUNK_SIZE = 100; const CHUNK_SIZE = 100;

View File

@ -0,0 +1,13 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('configuration:dump')
.alias('config:dump')
.description('Dump configurations of your application')
.option('-f, --file <file>', 'Output file, default output is stdout')
.option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)
.action(getLocalScript('configuration/dump'));
};

View File

@ -3,7 +3,7 @@
const fs = require('fs'); const fs = require('fs');
const _ = require('lodash'); const _ = require('lodash');
const strapi = require('../../index'); const strapi = require('../../../../index');
/** /**
* Will restore configurations. It reads from a file or stdin * Will restore configurations. It reads from a file or stdin

View File

@ -0,0 +1,13 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('configuration:restore')
.alias('config:restore')
.description('Restore configurations of your application')
.option('-f, --file <file>', 'Input file, default input is stdin')
.option('-s, --strategy <strategy>', 'Strategy name, one of: "replace", "merge", "keep"')
.action(getLocalScript('configuration/restore'));
};

View File

@ -0,0 +1,11 @@
'use strict';
const { loadProjectScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi console`
command
.command('console')
.description('Open the Strapi framework console')
.action(loadProjectScript('console'));
};

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi console` // `$ strapi console`

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('content-types:list')
.description('List all the application content-types')
.action(getLocalScript('content-types/list'));
};

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('controllers:list')
.description('List all the application controllers')
.action(getLocalScript('controllers/list'));
};

View File

@ -0,0 +1,16 @@
'use strict';
const { loadProjectScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi develop`
command
.command('develop')
.alias('dev')
.option('--no-build', 'Disable build')
.option('--watch-admin', 'Enable watch', false)
.option('--polling', 'Watch for file changes in network directories', false)
.option('--browser <name>', 'Open the browser', true)
.description('Start your Strapi application in development mode')
.action(loadProjectScript('develop'));
};

View File

@ -9,9 +9,9 @@ const { getOr } = require('lodash/fp');
const { joinBy } = require('@strapi/utils'); const { joinBy } = require('@strapi/utils');
const tsUtils = require('@strapi/typescript-utils'); const tsUtils = require('@strapi/typescript-utils');
const loadConfiguration = require('../../core/app-configuration'); const loadConfiguration = require('../../../core/app-configuration');
const strapi = require('../../index'); const strapi = require('../../../index');
const { buildTypeScript, buildAdmin } = require('../builders'); const { buildTypeScript, buildAdmin } = require('../../builders');
/** /**
* `$ strapi develop` * `$ strapi develop`

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi develop` // `$ strapi develop`

View File

@ -24,8 +24,8 @@ const {
loadersFactory, loadersFactory,
exitMessageText, exitMessageText,
abortTransfer, abortTransfer,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
const { exitWith } = require('../../scripts/utils/helpers'); const { exitWith } = require('../../utils/helpers');
/** /**
* @typedef ExportCommandOptions Options given to the CLI import command * @typedef ExportCommandOptions Options given to the CLI import command
* *

View File

@ -6,9 +6,9 @@ const {
onlyOption, onlyOption,
throttleOption, throttleOption,
validateExcludeOnly, validateExcludeOnly,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
const { promptEncryptionKey } = require('../../scripts/utils/commander'); const { promptEncryptionKey } = require('../../utils/commander');
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = (commandContext) => { module.exports = (commandContext) => {
const { command } = commandContext; const { command } = commandContext;

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { assertCwdContainsStrapiProject } = require('../../scripts/utils/helpers'); const { assertCwdContainsStrapiProject } = require('../../utils/helpers');
module.exports = ({ command, argv }) => { module.exports = ({ command, argv }) => {
// $ strapi generate // $ strapi generate

View File

@ -0,0 +1,11 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command }) => {
// `$ strapi generate:template <directory>`
command
.command('templates:generate <directory>')
.description('Generate template from Strapi project')
.action(getLocalScript('template/generate'));
};

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('hooks:list')
.description('List all the application hooks')
.action(getLocalScript('hooks/list'));
};

View File

@ -20,8 +20,8 @@ const {
loadersFactory, loadersFactory,
exitMessageText, exitMessageText,
abortTransfer, abortTransfer,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
const { exitWith } = require('../../scripts/utils/helpers'); const { exitWith } = require('../../utils/helpers');
/** /**
* @typedef {import('@strapi/data-transfer/src/file/providers').ILocalFileSourceProviderOptions} ILocalFileSourceProviderOptions * @typedef {import('@strapi/data-transfer/src/file/providers').ILocalFileSourceProviderOptions} ILocalFileSourceProviderOptions

View File

@ -8,9 +8,9 @@ const {
onlyOption, onlyOption,
throttleOption, throttleOption,
validateExcludeOnly, validateExcludeOnly,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
const { confirmMessage, forceOption } = require('../../scripts/utils/commander'); const { confirmMessage, forceOption } = require('../../utils/commander');
const { getLocalScript, exitWith } = require('../../scripts/utils/helpers'); const { getLocalScript, exitWith } = require('../../utils/helpers');
module.exports = (commandContext) => { module.exports = (commandContext) => {
const { command } = commandContext; const { command } = commandContext;

View File

@ -0,0 +1,11 @@
'use strict';
const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi install`
command
.command('install [plugins...]')
.description('Install a Strapi plugin')
.action(getLocalScript('install'));
};

View File

@ -4,7 +4,7 @@ const { join } = require('path');
const { existsSync } = require('fs-extra'); const { existsSync } = require('fs-extra');
const ora = require('ora'); const ora = require('ora');
const execa = require('execa'); const execa = require('execa');
const findPackagePath = require('../../load/package-path'); const findPackagePath = require('../../../load/package-path');
module.exports = async (plugins) => { module.exports = async (plugins) => {
const loader = ora(); const loader = ora();

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi install` // `$ strapi install`

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('middlewares:list')
.description('List all the application middlewares')
.action(getLocalScript('middlewares/list'));
};

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('policies:list')
.description('List all the application policies')
.action(getLocalScript('policies/list'));
};

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('routes:list')
.description('List all the application routes')
.action(getLocalScript('routes/list'));
};

View File

@ -0,0 +1,10 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
command
.command('services:list')
.description('List all the application services')
.action(getLocalScript('services/list'));
};

View File

@ -3,7 +3,7 @@
const CLITable = require('cli-table3'); const CLITable = require('cli-table3');
const chalk = require('chalk'); const chalk = require('chalk');
const strapi = require('../../../index'); const strapi = require('../../../../index');
module.exports = async function () { module.exports = async function () {
const appContext = await strapi.compile(); const appContext = await strapi.compile();

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
const { loadProjectScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi start` // `$ strapi start`
command command
.command('start') .command('start')
.description('Start your Strapi application') .description('Start your Strapi application')
.action(loadProjectScript('start')); .action(getLocalScript('start'));
}; };

View File

@ -4,7 +4,7 @@ const { resolve } = require('path');
const fse = require('fs-extra'); const fse = require('fs-extra');
const chalk = require('chalk'); const chalk = require('chalk');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const machineID = require('../../utils/machine-id'); const machineID = require('../../../../utils/machine-id');
const readPackageJSON = async (path) => { const readPackageJSON = async (path) => {
try { try {

View File

@ -0,0 +1,11 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi opt-out-telemetry`
command
.command('telemetry:disable')
.description('Disable anonymous telemetry and metadata sending to Strapi analytics')
.action(getLocalScript('telemetry/disable'));
};

View File

@ -5,7 +5,7 @@ const fse = require('fs-extra');
const chalk = require('chalk'); const chalk = require('chalk');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const { v4: uuidv4 } = require('uuid'); const { v4: uuidv4 } = require('uuid');
const machineID = require('../../utils/machine-id'); const machineID = require('../../../../utils/machine-id');
const readPackageJSON = async (path) => { const readPackageJSON = async (path) => {
try { try {

View File

@ -0,0 +1,11 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi opt-in-telemetry`
command
.command('telemetry:enable')
.description('Enable anonymous telemetry and metadata sending to Strapi analytics')
.action(getLocalScript('telemetry/enable'));
};

View File

@ -0,0 +1,11 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi generate:template <directory>`
command
.command('templates:generate <directory>')
.description('Generate template from Strapi project')
.action(getLocalScript('templates/generate'));
};

View File

@ -21,8 +21,8 @@ const {
loadersFactory, loadersFactory,
exitMessageText, exitMessageText,
abortTransfer, abortTransfer,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
const { exitWith } = require('../../scripts/utils/helpers'); const { exitWith } = require('../../utils/helpers');
/** /**
* @typedef TransferCommandOptions Options given to the CLI transfer command * @typedef TransferCommandOptions Options given to the CLI transfer command

View File

@ -2,19 +2,19 @@
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const { Option } = require('commander'); const { Option } = require('commander');
const { confirmMessage, forceOption, parseURL } = require('../../scripts/utils/commander'); const { confirmMessage, forceOption, parseURL } = require('../../utils/commander');
const { const {
getLocalScript, getLocalScript,
exitWith, exitWith,
assertUrlHasProtocol, assertUrlHasProtocol,
ifOptions, ifOptions,
} = require('../../scripts/utils/helpers'); } = require('../../utils/helpers');
const { const {
excludeOption, excludeOption,
onlyOption, onlyOption,
throttleOption, throttleOption,
validateExcludeOnly, validateExcludeOnly,
} = require('../../scripts/transfer/utils'); } = require('../../utils/data-transfer');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi transfer` // `$ strapi transfer`

View File

@ -2,7 +2,7 @@
const tsUtils = require('@strapi/typescript-utils'); const tsUtils = require('@strapi/typescript-utils');
const strapi = require('../../index'); const strapi = require('../../../../index');
module.exports = async function ({ outDir, file, verbose, silent }) { module.exports = async function ({ outDir, file, verbose, silent }) {
if (verbose && silent) { if (verbose && silent) {

View File

@ -0,0 +1,18 @@
'use strict';
const { getLocalScript } = require('../../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi ts:generate-types`
command
.command('ts:generate-types')
.description(`Generate TypeScript typings for your schemas`)
.option(
'-o, --out-dir <outDir>',
'Specify a relative directory in which the schemas definitions will be generated'
)
.option('-f, --file <file>', 'Specify a filename to store the schemas definitions')
.option('--verbose', `Display more information about the types generation`, false)
.option('-s, --silent', `Run the generation silently, without any output`, false)
.action(getLocalScript('ts/generate-types'));
};

View File

@ -0,0 +1,12 @@
'use strict';
const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => {
// `$ strapi uninstall`
command
.command('uninstall [plugins...]')
.description('Uninstall a Strapi plugin')
.option('-d, --delete-files', 'Delete files', false)
.action(getLocalScript('uninstall'));
};

View File

@ -5,7 +5,7 @@ const { existsSync, removeSync } = require('fs-extra');
const ora = require('ora'); const ora = require('ora');
const execa = require('execa'); const execa = require('execa');
const inquirer = require('inquirer'); const inquirer = require('inquirer');
const findPackagePath = require('../../load/package-path'); const findPackagePath = require('../../../load/package-path');
module.exports = async (plugins, { deleteFiles }) => { module.exports = async (plugins, { deleteFiles }) => {
const answers = await inquirer.prompt([ const answers = await inquirer.prompt([

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi uninstall` // `$ strapi uninstall`

View File

@ -3,9 +3,9 @@
const strapiAdmin = require('@strapi/admin'); const strapiAdmin = require('@strapi/admin');
const { getConfigUrls, getAbsoluteServerUrl } = require('@strapi/utils'); const { getConfigUrls, getAbsoluteServerUrl } = require('@strapi/utils');
const getEnabledPlugins = require('../../core/loaders/plugins/get-enabled-plugins'); const getEnabledPlugins = require('../../../core/loaders/plugins/get-enabled-plugins');
const addSlash = require('../../utils/addSlash'); const addSlash = require('../../../utils/addSlash');
const strapi = require('../../index'); const strapi = require('../../../index');
module.exports = async function ({ browser }) { module.exports = async function ({ browser }) {
const appContext = await strapi.compile(); const appContext = await strapi.compile();

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { getLocalScript } = require('../../scripts/utils/helpers'); const { getLocalScript } = require('../../utils/helpers');
module.exports = ({ command /* , argv */ }) => { module.exports = ({ command /* , argv */ }) => {
// `$ strapi watch-admin` // `$ strapi watch-admin`
@ -8,5 +8,5 @@ module.exports = ({ command /* , argv */ }) => {
.command('watch-admin') .command('watch-admin')
.option('--browser <name>', 'Open the browser', true) .option('--browser <name>', 'Open the browser', true)
.description('Start the admin development server') .description('Start the admin development server')
.action(getLocalScript('watchAdmin')); .action(getLocalScript('watch-admin'));
}; };

View File

@ -2,7 +2,37 @@
const { Command } = require('commander'); const { Command } = require('commander');
const availableCommands = ['version', 'console', 'new', 'export', 'import']; const availableCommands = [
'admin/create-user',
'admin/reset-user-password',
'build-action', // TODO: this should be 'build' but that is ignored
'configuration/dump',
'configuration/restore',
'console',
'content-types/list',
'controllers/list',
'develop',
'export',
'generate',
'generate/template',
'hooks/list',
'import',
'install',
'middlewares/list',
'new',
'policies/list',
'routes/list',
'services/list',
'start',
'telemetry/disable',
'telemetry/enable',
'templates/generate',
'transfer',
'ts/generate-types',
'uninstall',
'version',
'watch-admin',
];
const buildStrapiCommand = (argv, command = new Command()) => { const buildStrapiCommand = (argv, command = new Command()) => {
// Initial program setup // Initial program setup
@ -20,112 +50,6 @@ const buildStrapiCommand = (argv, command = new Command()) => {
} }
}); });
/*
// `$ strapi generate:template <directory>`
command
.command('templates:generate <directory>')
.description('Generate template from Strapi project')
.action(getLocalScript('generate-template'));
command
.command('configuration:dump')
.alias('config:dump')
.description('Dump configurations of your application')
.option('-f, --file <file>', 'Output file, default output is stdout')
.option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)
.action(getLocalScript('configurationDump'));
command
.command('configuration:restore')
.alias('config:restore')
.description('Restore configurations of your application')
.option('-f, --file <file>', 'Input file, default input is stdin')
.option('-s, --strategy <strategy>', 'Strategy name, one of: "replace", "merge", "keep"')
.action(getLocalScript('configurationRestore'));
// Admin
command
.command('admin:create-user')
.alias('admin:create')
.description('Create a new admin')
.option('-e, --email <email>', 'Email of the new admin')
.option('-p, --password <password>', 'Password of the new admin')
.option('-f, --firstname <first name>', 'First name of the new admin')
.option('-l, --lastname <last name>', 'Last name of the new admin')
.action(getLocalScript('admin-create'));
command
.command('admin:reset-user-password')
.alias('admin:reset-password')
.description("Reset an admin user's password")
.option('-e, --email <email>', 'The user email')
.option('-p, --password <password>', 'New password for the user')
.action(getLocalScript('admin-reset'));
command
.command('routes:list')
.description('List all the application routes')
.action(getLocalScript('routes/list'));
command
.command('middlewares:list')
.description('List all the application middlewares')
.action(getLocalScript('middlewares/list'));
command
.command('policies:list')
.description('List all the application policies')
.action(getLocalScript('policies/list'));
command
.command('content-types:list')
.description('List all the application content-types')
.action(getLocalScript('content-types/list'));
command
.command('hooks:list')
.description('List all the application hooks')
.action(getLocalScript('hooks/list'));
command
.command('services:list')
.description('List all the application services')
.action(getLocalScript('services/list'));
command
.command('controllers:list')
.description('List all the application controllers')
.action(getLocalScript('controllers/list'));
// `$ strapi opt-out-telemetry`
command
.command('telemetry:disable')
.description('Disable anonymous telemetry and metadata sending to Strapi analytics')
.action(getLocalScript('opt-out-telemetry'));
// `$ strapi opt-in-telemetry`
command
.command('telemetry:enable')
.description('Enable anonymous telemetry and metadata sending to Strapi analytics')
.action(getLocalScript('opt-in-telemetry'));
command
.command('ts:generate-types')
.description(`Generate TypeScript typings for your schemas`)
.option(
'-o, --out-dir <outDir>',
'Specify a relative directory in which the schemas definitions will be generated'
)
.option('-f, --file <file>', 'Specify a filename to store the schemas definitions')
.option('--verbose', `Display more information about the types generation`, false)
.option('-s, --silent', `Run the generation silently, without any output`, false)
.action(getLocalScript('ts/generate-types'));
*/
return command; return command;
}; };

View File

@ -12,9 +12,9 @@ const {
createLogger, createLogger,
} = require('@strapi/logger'); } = require('@strapi/logger');
const ora = require('ora'); const ora = require('ora');
const { readableBytes, exitWith } = require('../utils/helpers'); const { readableBytes, exitWith } = require('./helpers');
const strapi = require('../../../index'); const strapi = require('../../index');
const { getParseListWithChoices, parseInteger } = require('../utils/commander'); const { getParseListWithChoices, parseInteger } = require('./commander');
const exitMessageText = (process, error = false) => { const exitMessageText = (process, error = false) => {
const processCapitalized = process[0].toUpperCase() + process.slice(1); const processCapitalized = process[0].toUpperCase() + process.slice(1);

View File

@ -133,7 +133,7 @@ const getLocalScript =
(name) => (name) =>
(...args) => { (...args) => {
assertCwdContainsStrapiProject(name); assertCwdContainsStrapiProject(name);
console.log('getLocalScript', name);
const cmdPath = resolveCwd.silent(`@strapi/strapi/lib/commands/actions/${name}/action`); const cmdPath = resolveCwd.silent(`@strapi/strapi/lib/commands/actions/${name}/action`);
if (!cmdPath) { if (!cmdPath) {
console.log( console.log(