diff --git a/.eslintignore b/.eslintignore index 2633eeedbd..26c10e7162 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,15 +5,11 @@ testApp/** examples/** cypress/** -packages/generators/plugin/files/admin/src/** +packages/generators/generators/lib/files/ packages/core/helper-plugin/build/** packages/core/helper-plugin/lib/src/components/** packages/core/helper-plugin/lib/src/testUtils/** packages/core/helper-plugin/lib/src/utils/** -packages/plugins/users-permissions/admin/OLD/** .eslintrc.js .eslintrc.front.js .eslintrc.back.js - -bookshelf.old -database.old diff --git a/examples/getstarted/package.json b/examples/getstarted/package.json index 956e78be23..4031a6ead4 100644 --- a/examples/getstarted/package.json +++ b/examples/getstarted/package.json @@ -40,4 +40,4 @@ "npm": ">=6.0.0" }, "license": "SEE LICENSE IN LICENSE" -} +} \ No newline at end of file diff --git a/packages/core/content-type-builder/package.json b/packages/core/content-type-builder/package.json index 32453dfd28..250c00dbde 100644 --- a/packages/core/content-type-builder/package.json +++ b/packages/core/content-type-builder/package.json @@ -11,8 +11,7 @@ }, "dependencies": { "@sindresorhus/slugify": "1.1.0", - "@strapi/generate": "3.6.8", - "@strapi/generate-api": "3.6.8", + "@strapi/generators": "3.6.8", "@strapi/helper-plugin": "3.6.8", "@strapi/utils": "3.6.8", "fs-extra": "^9.1.0", diff --git a/packages/core/content-type-builder/server/services/content-types.js b/packages/core/content-type-builder/server/services/content-types.js index c6a271eaa1..0fd1615ce7 100644 --- a/packages/core/content-type-builder/server/services/content-types.js +++ b/packages/core/content-type-builder/server/services/content-types.js @@ -2,7 +2,7 @@ const _ = require('lodash'); const { getOr } = require('lodash/fp'); -const generator = require('@strapi/generate'); +const strapiGenerators = require('@strapi/generators'); const { nameToSlug, contentTypes: contentTypesUtils } = require('@strapi/utils'); const { formatAttributes, replaceTemporaryUIDs } = require('../utils/attributes'); @@ -127,23 +127,7 @@ const createContentType = async ({ contentType, components = [] }, options = {}) * @param {string} name */ const generateAPI = ({ name, kind = 'collectionType' }) => { - return new Promise((resolve, reject) => { - const scope = { - generatorType: 'api', - id: nameToSlug(name), - name: nameToSlug(name), - rootPath: strapi.dir, - args: { - attributes: {}, - kind, - }, - }; - - generator(scope, { - success: () => resolve(), - error: err => reject(err), - }); - }); + return strapiGenerators.generate('api', { id: nameToSlug(name), kind }, { dir: strapi.dir }); }; /** diff --git a/packages/core/strapi/bin/strapi.js b/packages/core/strapi/bin/strapi.js index 2930fc11b0..db09a7b8bb 100755 --- a/packages/core/strapi/bin/strapi.js +++ b/packages/core/strapi/bin/strapi.js @@ -118,68 +118,22 @@ program .description('Start your Strapi application in development mode') .action(getLocalScript('develop')); -// `$ strapi generate:api` +// $ strapi generate program - .command('generate:api [attributes...]') - .option('-a, --api ', 'API name to generate the files in') - .option('-p, --plugin ', 'Name of the local plugin') - .option('-e, --extend ', 'Name of the plugin to extend') - .option('--draft-and-publish', 'Enable draft/publish', false) - .description('Generate a basic API') - .action((id, attributes, cliArguments) => { - cliArguments.attributes = attributes; - getLocalScript('generate')(id, cliArguments); + .command('generate') + .description('Launch interactive API generator') + .action(() => { + checkCwdIsStrapiApp('generate'); + process.argv.splice(2, 1); + require('@strapi/generators').runCLI(); }); -// `$ strapi generate:controller` -program - .command('generate:controller ') - .option('-a, --api ', 'API name to generate the files in') - .option('-p, --plugin ', 'Name of the local plugin') - .option('-e, --extend ', 'Name of the plugin to extend') - .description('Generate a controller for an API') - .action(getLocalScript('generate')); - -// `$ strapi generate:model` -program - .command('generate:model [attributes...]') - .option('-a, --api ', 'API name to generate a sub API') - .option('-p, --plugin ', 'plugin name') - .option('--draft-and-publish', 'Enable draft/publish', false) - .description('Generate a model for an API') - .action((id, attributes, cliArguments) => { - cliArguments.attributes = attributes; - getLocalScript('generate')(id, cliArguments); - }); - -// `$ strapi generate:policy` -program - .command('generate:policy ') - .option('-a, --api ', 'API name') - .option('-p, --plugin ', 'plugin name') - .description('Generate a policy for an API') - .action(getLocalScript('generate')); - -// `$ strapi generate:service` -program - .command('generate:service ') - .option('-a, --api ', 'API name') - .option('-p, --plugin ', 'plugin name') - .description('Generate a service for an API') - .action(getLocalScript('generate')); - -// `$ strapi generate:plugin` -program - .command('generate:plugin ') - .option('-n, --name ', 'Plugin name') - .description('Generate a basic plugin') - .action(getLocalScript('generate')); - // `$ strapi generate:template ` program .command('generate:template ') .description('Generate template from Strapi project') .action(getLocalScript('generate-template')); + program .command('build') .option('--clean', 'Remove the build and .cache folders', false) diff --git a/packages/core/strapi/lib/commands/generate.js b/packages/core/strapi/lib/commands/generate.js deleted file mode 100644 index 11c5d7fb87..0000000000 --- a/packages/core/strapi/lib/commands/generate.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// FIXME -/* eslint-disable import/extensions */ - -// Node.js core. -const path = require('path'); - -// Master of ceremonies for generators. -const generate = require('@strapi/generate'); - -// Logger. -const { createLogger } = require('@strapi/logger'); - -// Configuration -const loadConfiguration = require('../core/app-configuration'); - -// Local Strapi dependencies. -const packageJSON = require('../../package.json'); - -/** - * `$ strapi generate` - * - * Scaffolding for the application in our working directory. - */ - -module.exports = function(id, cliArguments) { - const dir = process.cwd(); - const config = loadConfiguration(dir); - const logger = createLogger(config.get('logger', {})); - - // Build initial scope. - const scope = { - rootPath: process.cwd(), - strapiRoot: path.resolve(__dirname, '..'), - id: id, - args: cliArguments, - strapiPackageJSON: packageJSON, - }; - - scope.generatorType = process.argv[2].split(':')[1]; - - // Show usage if no generator type is defined. - if (!scope.generatorType) { - return logger.error('Write `$ strapi generate:something` instead.'); - } - - return generate(scope, { - // Log and exit the REPL in case there is an error - // while we were trying to generate the requested generator. - error(msg) { - logger.error(msg); - process.exit(1); - }, - - // Log and exit the REPL in case of success - // but first make sure we have all the info we need. - success() { - if (!scope.outputPath && scope.filename && scope.destDir) { - scope.outputPath = scope.destDir + scope.filename; - } - - if (scope.generatorType !== 'new') { - logger.info( - `Generated a new ${scope.generatorType} \`${scope.name}\` at \`${scope.filePath}\`.` - ); - } - - process.exit(0); - }, - }); -}; diff --git a/packages/core/strapi/package.json b/packages/core/strapi/package.json index a4bc243626..035bd65a67 100644 --- a/packages/core/strapi/package.json +++ b/packages/core/strapi/package.json @@ -16,14 +16,8 @@ "@koa/cors": "^3.0.0", "@strapi/admin": "3.6.8", "@strapi/database": "3.6.8", - "@strapi/generate": "3.6.8", - "@strapi/generate-api": "3.6.8", - "@strapi/generate-controller": "3.6.8", - "@strapi/generate-model": "3.6.8", + "@strapi/generators": "3.6.8", "@strapi/generate-new": "3.6.8", - "@strapi/generate-plugin": "3.6.8", - "@strapi/generate-policy": "3.6.8", - "@strapi/generate-service": "3.6.8", "@strapi/logger": "3.6.8", "@strapi/utils": "3.6.8", "async": "^2.1.2", @@ -64,6 +58,7 @@ "open": "8.2.1", "ora": "^5.4.0", "package-json": "6.5.0", + "plop": "2.7.4", "pluralize": "8.0.0", "qs": "^6.10.1", "resolve-cwd": "^3.0.0", diff --git a/packages/generators/api/.editorconfig b/packages/generators/api/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/api/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/api/.gitignore b/packages/generators/api/.gitignore deleted file mode 100644 index 1681516f06..0000000000 --- a/packages/generators/api/.gitignore +++ /dev/null @@ -1,102 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/api/.npmignore b/packages/generators/api/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/api/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/api/.snyk b/packages/generators/api/.snyk deleted file mode 100644 index dad193f2df..0000000000 --- a/packages/generators/api/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:35:54.864Z -patch: {} diff --git a/packages/generators/api/LICENSE b/packages/generators/api/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/api/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/api/README.md b/packages/generators/api/README.md deleted file mode 100644 index 3781ae6973..0000000000 --- a/packages/generators/api/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# strapi-generate-api - -[![npm version](https://img.shields.io/npm/v/strapi-generate-api.svg)](https://www.npmjs.org/package/strapi-generate-api) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-api.svg)](https://www.npmjs.org/package/strapi-generate-api) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-api.svg)](https://david-dm.org/strapi/strapi-generate-api) -[![Build status](https://travis-ci.org/strapi/strapi-generate-api.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-api) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains all the default files for a new API. - -This generator can be called with: - -```bash -$ strapi generate:api apiName -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/api/jest.config.js b/packages/generators/api/jest.config.js deleted file mode 100644 index e7d225f24d..0000000000 --- a/packages/generators/api/jest.config.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = { - name: 'generate-api', - displayName: 'Generated API', - testMatch: ['**/test/?(*.)+(spec|test).js'], -}; diff --git a/packages/generators/api/json/routes.json.js b/packages/generators/api/json/routes.json.js deleted file mode 100644 index 8b063eb370..0000000000 --- a/packages/generators/api/json/routes.json.js +++ /dev/null @@ -1,108 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const fs = require('fs'); - -// Public node modules. -const _ = require('lodash'); - -function generateSingleTypeRoutes({ route, name }) { - return [ - { - method: 'GET', - path: '/' + route, - handler: name + '.find', - config: { - policies: [], - }, - }, - { - method: 'PUT', - path: '/' + route, - handler: name + '.update', - config: { - policies: [], - }, - }, - { - method: 'DELETE', - path: '/' + route, - handler: name + '.delete', - config: { - policies: [], - }, - }, - ]; -} - -function generateCollectionTypeRoutes({ route, name }) { - return [ - { - method: 'GET', - path: '/' + route, - handler: name + '.find', - config: { - policies: [], - }, - }, - { - method: 'GET', - path: '/' + route + '/:id', - handler: name + '.findOne', - config: { - policies: [], - }, - }, - { - method: 'POST', - path: '/' + route, - handler: name + '.create', - config: { - policies: [], - }, - }, - { - method: 'PUT', - path: '/' + route + '/:id', - handler: name + '.update', - config: { - policies: [], - }, - }, - { - method: 'DELETE', - path: '/' + route + '/:id', - handler: name + '.delete', - config: { - policies: [], - }, - }, - ]; -} - -/** - * Expose main routes of the generated API - */ - -module.exports = scope => { - let routes = []; - if (!scope.args.plugin) { - routes = - scope.contentTypeKind === 'singleType' - ? generateSingleTypeRoutes({ route: scope.route, name: scope.name }) - : generateCollectionTypeRoutes({ route: scope.route, name: scope.name }); - } - - // if routes.json already exists, then merge - if (fs.existsSync(scope.rootPath)) { - let current = require(scope.rootPath); - fs.unlinkSync(scope.rootPath); - routes = _.concat(routes, _.differenceWith(current.routes, routes, _.isEqual)); - } - - return { routes }; -}; diff --git a/packages/generators/api/lib/before.js b/packages/generators/api/lib/before.js deleted file mode 100644 index 43ed03a70b..0000000000 --- a/packages/generators/api/lib/before.js +++ /dev/null @@ -1,138 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); -const pluralize = require('pluralize'); -const { nameToSlug } = require('@strapi/utils'); - -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid('Usage: `$ strapi generate:api apiName`'); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - scope.contentTypeKind = scope.args.kind || 'collectionType'; - - // `scope.args` are the raw command line arguments. - _.defaults(scope, { - name, - route: - scope.contentTypeKind === 'singleType' - ? _.kebabCase(scope.id) - : _.kebabCase(pluralize(scope.id)), - }); - - let filePath; - if (scope.args.api) { - filePath = `./api/${scope.args.api}`; - } else if (scope.args.plugin) { - filePath = `./plugins/${scope.args.plugin}`; - } else if (scope.args.extend) { - filePath = `./extensions/${scope.args.extend}`; - } else { - filePath = `./api/${name}`; - } - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - filename: `${name}.js`, - filenameSettings: `${name}.settings.json`, - filePath, - }); - - // Validate optional attribute arguments. - const invalidAttributes = []; - - if (_.isPlainObject(scope.args.attributes)) { - scope.attributes = scope.args.attributes; - } else { - // Map attributes and split them for CLI. - scope.attributes = scope.args.attributes.map(attribute => { - if (_.isString(attribute)) { - const parts = attribute.split(':'); - - parts[1] = parts[1] || 'string'; - - // Handle invalid attributes. - if (!parts[1] || !parts[0]) { - invalidAttributes.push('Error: Invalid attribute notation `' + attribute + '`.'); - return; - } - - return { - name: _.trim(_.deburr(parts[0].toLowerCase())), - params: { - type: _.trim(_.deburr(parts[1].toLowerCase())), - }, - }; - } else { - return _.has(attribute, 'params.type') ? attribute : undefined; - } - }); - - scope.attributes = _.compact(scope.attributes); - - // Handle invalid action arguments. - // Send back invalidActions. - if (invalidAttributes.length) { - return cb.invalid(invalidAttributes); - } - - // Make sure there aren't duplicates. - if ( - _(scope.attributes.map(attribute => attribute.name)) - .uniq() - .valueOf().length !== scope.attributes.length - ) { - return cb.invalid('Duplicate attributes not allowed!'); - } - - // Render some stringified code from the action template - // and make it available in our scope for use later on. - scope.attributes = scope.attributes.reduce((acc, attribute) => { - acc[attribute.name] = attribute.params; - return acc; - }, {}); - } - // Set collectionName - scope.collectionName = _.has(scope.args, 'collectionName') - ? scope.args.collectionName - : _.snakeCase(pluralize(name)); - - // Set description - scope.description = _.has(scope.args, 'description') ? scope.args.description : ''; - - scope.schema = JSON.stringify( - { - collectionName: scope.collectionName, - info: { - name: scope.args.displayName || scope.id, - description: scope.description, - }, - options: { - draftAndPublish: scope.args.draftAndPublish === 'true', - comment: '', - }, - attributes: scope.attributes, - }, - null, - 2 - ); - - // Trigger callback with no error to proceed. - return cb.success(); -}; diff --git a/packages/generators/api/lib/index.js b/packages/generators/api/lib/index.js deleted file mode 100644 index cdcbe909db..0000000000 --- a/packages/generators/api/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// FIXME -/* eslint-disable import/extensions */ - -// Local dependencies. -const routesJSON = require('../json/routes.json.js'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - // Use the default `controller` file as a template for - // every generated controller. - ':filePath/controllers/:filename': { - template: 'controller.template', - }, - - // every generated controller. - ':filePath/services/:filename': { - template: 'service.template', - }, - - // Copy an empty JavaScript model where every functions will be. - ':filePath/models/:filename': { - template: 'model.template', - }, - - // Copy the generated JSON model for the connection, - // schema and attributes. - ':filePath/models/:filenameSettings': { - template: 'model.settings.template', - }, - - // Generate routes. - ':filePath/config/routes.json': { - jsonfile: routesJSON, - }, - }, -}; diff --git a/packages/generators/api/package.json b/packages/generators/api/package.json deleted file mode 100644 index bb6019b1cc..0000000000 --- a/packages/generators/api/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@strapi/generate-api", - "version": "3.6.8", - "description": "Generate an API for a Strapi application.", - "homepage": "https://strapi.io", - "keywords": [ - "generate", - "generator", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "dependencies": { - "lodash": "4.17.21", - "pluralize": "^8.0.0", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "author": { - "email": "hi@strapi.io", - "name": "Strapi team", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/generators/api/templates/controller.template b/packages/generators/api/templates/controller.template deleted file mode 100644 index e860895393..0000000000 --- a/packages/generators/api/templates/controller.template +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -/** - * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers) - * to customize this controller - */ - -module.exports = {}; diff --git a/packages/generators/api/templates/model.settings.template b/packages/generators/api/templates/model.settings.template deleted file mode 100644 index ae62b4b5c5..0000000000 --- a/packages/generators/api/templates/model.settings.template +++ /dev/null @@ -1 +0,0 @@ -<%= schema %> diff --git a/packages/generators/api/templates/model.template b/packages/generators/api/templates/model.template deleted file mode 100644 index 0054d33c1e..0000000000 --- a/packages/generators/api/templates/model.template +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -/** - * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#lifecycle-hooks) - * to customize this model - */ - -module.exports = {}; diff --git a/packages/generators/api/templates/service.template b/packages/generators/api/templates/service.template deleted file mode 100644 index 6538a8c86b..0000000000 --- a/packages/generators/api/templates/service.template +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -/** - * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-services) - * to customize this service - */ - -module.exports = {}; diff --git a/packages/generators/controller/.editorconfig b/packages/generators/controller/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/controller/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/controller/.npmignore b/packages/generators/controller/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/controller/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/controller/.snyk b/packages/generators/controller/.snyk deleted file mode 100644 index 21c1b06e09..0000000000 --- a/packages/generators/controller/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:35:57.351Z -patch: {} diff --git a/packages/generators/controller/LICENSE b/packages/generators/controller/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/controller/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/controller/README.md b/packages/generators/controller/README.md deleted file mode 100644 index 5f3737add8..0000000000 --- a/packages/generators/controller/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# strapi-generate-controller - -[![npm version](https://img.shields.io/npm/v/strapi-generate-controller.svg)](https://www.npmjs.org/package/strapi-generate-controller) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-controller.svg)](https://www.npmjs.org/package/strapi-generate-controller) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-controller.svg)](https://david-dm.org/strapi/strapi-generate-controller) -[![Build status](https://travis-ci.org/strapi/strapi-generate-controller.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-controller) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains the default files for a controller. - -This generator can be called with: - -```bash -$ strapi generate:controller controllerName apiName -``` - -For example if you want to generate a `group` controller for the `user` API: - -```bash -$ strapi generate:controller group user -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/controller/lib/before.js b/packages/generators/controller/lib/before.js deleted file mode 100644 index 8ffc5e5ab0..0000000000 --- a/packages/generators/controller/lib/before.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); -const { nameToSlug } = require('@strapi/utils'); -/* eslint-disable prefer-template */ -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid( - 'Usage: `$ strapi generate:controller controllerName --api apiName --plugin pluginName`' - ); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - // `scope.args` are the raw command line arguments. - _.defaults(scope, { - name, - api: scope.id, - }); - - // Determine the destination path. - let filePath; - if (scope.args.api) { - filePath = `./api/${scope.args.api}/controllers`; - } else if (scope.args.plugin) { - filePath = `./plugins/${scope.args.plugin}/controllers`; - } else if (scope.args.extend) { - filePath = `./extensions/${scope.args.extend}/controllers`; - } else { - filePath = `./api/${name}/controllers`; - } - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - rootPath: scope.rootPath, - filePath, - filename: `${name}.js`, - }); - - // Trigger callback with no error to proceed. - return cb(); -}; diff --git a/packages/generators/controller/lib/index.js b/packages/generators/controller/lib/index.js deleted file mode 100644 index 778338ace0..0000000000 --- a/packages/generators/controller/lib/index.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - ':filePath/:filename': { - template: 'controller.template', - }, - }, -}; diff --git a/packages/generators/controller/package.json b/packages/generators/controller/package.json deleted file mode 100644 index ec367993a3..0000000000 --- a/packages/generators/controller/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@strapi/generate-controller", - "version": "3.6.8", - "description": "Generate a controller for a Strapi API.", - "homepage": "https://strapi.io", - "keywords": [ - "controller", - "generate", - "generator", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "dependencies": { - "lodash": "4.17.21", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "author": { - "email": "hi@strapi.io", - "name": "Strapi team", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/generators/generate/.editorconfig b/packages/generators/generate/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/generate/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/generate/.gitignore b/packages/generators/generate/.gitignore deleted file mode 100644 index 47e0ea73cc..0000000000 --- a/packages/generators/generate/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - - - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/generate/.npmignore b/packages/generators/generate/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/generate/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/generate/.snyk b/packages/generators/generate/.snyk deleted file mode 100644 index 537461afdd..0000000000 --- a/packages/generators/generate/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:35:22.585Z -patch: {} diff --git a/packages/generators/generate/README.md b/packages/generators/generate/README.md deleted file mode 100644 index 1946bede6a..0000000000 --- a/packages/generators/generate/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# strapi-generate - -[![npm version](https://img.shields.io/npm/v/strapi-generate.svg)](https://www.npmjs.org/package/strapi-generate) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate.svg)](https://www.npmjs.org/package/strapi-generate) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate.svg)](https://david-dm.org/strapi/strapi-generate) -[![Build status](https://travis-ci.org/strapi/strapi-generate.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -Master of ceremonies for generators in the Strapi CLI. - -Usage: - -```bash -$ strapi generate:something -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/generate/lib/generate.js b/packages/generators/generate/lib/generate.js deleted file mode 100644 index d47ed93544..0000000000 --- a/packages/generators/generate/lib/generate.js +++ /dev/null @@ -1,188 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); -const util = require('util'); - -// Public node modules. -const _ = require('lodash'); -const async = require('async'); -const reportback = require('reportback')(); - -// Local dependencies. -const pathRegexp = require('./util').pathRegexp; -const generateTarget = require('./target'); - -/** - * Run a generator given an existing scope - * - * @param {Object} generator - * @param {Object} scope - * @param {Switchback} cb - */ - -/* eslint-disable prefer-template */ -function generate(generator, scope, cb) { - const sb = reportback.extend(cb, { - error: cb.error, - invalid: cb.invalid, - alreadyExists: 'error', - }); - - // Resolve string shorthand for generator defs - // to `{ generator: 'originalDef' }`. - if (typeof generator === 'string') { - const generatorName = generator; - generator = { - generator: generatorName, - }; - } - - // Run the generator's `before()` method proceeding. - generator.before( - scope, - reportback.extend({ - error: sb.error, - invalid: sb.invalid, - success: () => { - // Process all of the generator's targets concurrently. - async.each( - Object.keys(generator.targets), - (keyPath, asyncEachCb) => { - const asyncEachSb = reportback.extend(asyncEachCb); - - // Create a new scope object for this target, - // with references to the important bits of the original - // (depth will be passed-by-value, but that's what we want). - // Then generate the target, passing along a reference to - // the base `generate` method to allow for recursive generators. - const target = generator.targets[keyPath]; - if (!target) { - return asyncEachSb( - new Error( - 'Error: Invalid target: {"' + keyPath + '": ' + util.inspect(target) + '}' - ) - ); - } - - // Input tolerance. - if (keyPath === '') { - keyPath = '.'; - } - - // Interpret `keyPath` using Express's parameterized route conventions, - // first parsing params, then replacing them with their proper values from scope. - const params = []; - pathRegexp(keyPath, params); - let err; - const parsedKeyPath = _.reduce( - params, - (memoKeyPath, param) => { - if (err) { - return false; - } - - try { - const paramMatchExpr = ':' + param.name; - let actualParamValue = scope[param.name]; - if (!actualParamValue) { - err = new Error( - 'generator error:\n' + - 'A scope variable (`' + - param.name + - '`) was referenced in target: `' + - memoKeyPath + - '`,\n' + - 'but `' + - param.name + - "` does not exist in the generator's scope." - ); - return false; - } - actualParamValue = String(actualParamValue); - - return memoKeyPath.replace(paramMatchExpr, actualParamValue); - } catch (e) { - err = new Error('Error: Could not parse target key ' + memoKeyPath); - err.message = e; - return false; - } - }, - keyPath - ); - if (!parsedKeyPath) { - return asyncEachSb(err); - } - - // Create path from `rootPath` to `keyPath` to use as the `rootPath` - // for any generators or helpers in this target - // (use a copy so that child generators don't mutate the scope). - const targetScope = _.merge({}, scope, { - rootPath: path.resolve(scope.rootPath, parsedKeyPath), - - // Include reference to original keypath for error reporting. - keyPath, - }); - - // If `target` is an array, run each item. - if (_.isArray(target)) { - async.eachSeries( - target, - (targetItem, asyncEachSeriesCb) => { - generateTarget( - { - target: targetItem, - parent: generator, - scope: _.cloneDeep(targetScope), - recursiveGenerate: generate, - }, - asyncEachSeriesCb - ); - }, - asyncEachSb - ); - return; - } - - // Otherwise, just run the single target generator/helper. - generateTarget( - { - target, - parent: generator, - scope: targetScope, - recursiveGenerate: generate, - }, - asyncEachSb - ); - }, - - err => { - // Expose a `error` handler in generators. - if (err) { - const errorFn = - generator.error || - function defaultError(err, scope, _cb) { - return _cb(err); - }; - return errorFn(err, scope, sb); - } - - // Expose a `after` handler in generators (on success only). - const afterFn = - generator.after || - function defaultAfter(scope, _cb) { - return _cb(); - }; - return afterFn(scope, sb); - } - ); - }, - }) - ); -} - -module.exports = generate; diff --git a/packages/generators/generate/lib/helpers/copy/index.js b/packages/generators/generate/lib/helpers/copy/index.js deleted file mode 100644 index 59d3c58377..0000000000 --- a/packages/generators/generate/lib/helpers/copy/index.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// Public node modules. -const _ = require('lodash'); -const fs = require('fs-extra'); -const reportback = require('reportback')(); - -// Local dependencies. -const fileHelper = require('../file'); - -/** - * Copy file from one place to another - */ - -module.exports = function(options, cb) { - cb = reportback.extend(cb, { - alreadyExists: 'error', - invalid: 'error', - }); - - // Compute the canonical path to copy from - // given its relative path from its source generator's - // `templates` directory. - const absSrcPath = path.resolve(options.templatesDirectory, options.templatePath); - - fs.readFile(absSrcPath, 'utf8', (err, contents) => { - if (err) { - return cb.error(err); - } - - return fileHelper( - _.merge(options, { - contents, - }), - cb - ); - }); -}; diff --git a/packages/generators/generate/lib/helpers/file/index.js b/packages/generators/generate/lib/helpers/file/index.js deleted file mode 100644 index f6a53ea2f8..0000000000 --- a/packages/generators/generate/lib/helpers/file/index.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// Public node modules. -const _ = require('lodash'); -const async = require('async'); -const fs = require('fs-extra'); -const reportback = require('reportback')(); - -/** - * Generate a file using the specified string - */ - -/* eslint-disable prefer-template */ -module.exports = function(options, cb) { - // Provide default values for switchback. - cb = reportback.extend(cb, { - alreadyExists: 'error', - }); - - // Provide defaults and validate required options. - _.defaults(options, { - force: false, - }); - - const missingOpts = _.difference(['contents', 'rootPath'], Object.keys(options)); - - if (missingOpts.length) { - return cb.invalid(missingOpts); - } - - // In case we ended up here with a relative path, - // resolve it using the process's CWD - const rootPath = path.resolve(process.cwd(), options.rootPath); - - // Only override an existing file if `options.force` is true. - fs.exists(rootPath, exists => { - if (exists && !options.force) { - return cb.alreadyExists('Something else already exists at `' + rootPath + '`.'); - } - - // Don't actually write the file if this is a dry run. - if (options.dry) { - return cb.success(); - } - - async.series( - [ - function deleteExistingFileIfNecessary(cb) { - if (!exists) { - return cb(); - } - return fs.remove(rootPath, cb); - }, - function writeToDisk(cb) { - fs.outputFile(rootPath, options.contents, cb); - }, - ], - cb - ); - }); -}; diff --git a/packages/generators/generate/lib/helpers/folder/index.js b/packages/generators/generate/lib/helpers/folder/index.js deleted file mode 100644 index 47b10d6460..0000000000 --- a/packages/generators/generate/lib/helpers/folder/index.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// Public node modules. -const _ = require('lodash'); -const fs = require('fs-extra'); -const reportback = require('reportback')(); - -/** - * Generate a folder - */ -/* eslint-disable prefer-template */ -module.exports = function(options, cb) { - // Provide default values for cb. - cb = reportback.extend(cb, { - alreadyExists: 'error', - invalid: 'error', - }); - - // Provide defaults and validate required options. - _.defaults(options, { - force: false, - gitkeep: false, - }); - - const missingOpts = _.difference(['rootPath'], Object.keys(options)); - - if (missingOpts.length) { - return cb.invalid(missingOpts); - } - - const rootPath = path.resolve(process.cwd(), options.rootPath); - - // Only override an existing folder if `options.force` is true. - fs.lstat(rootPath, err => { - const exists = !(err && err.code === 'ENOENT'); - if (exists && err) { - return cb.error(err); - } - - if (exists && !options.force) { - return cb.alreadyExists('Something else already exists at `' + rootPath + '`.'); - } - - if (exists) { - fs.remove(rootPath, err => { - if (err) { - return cb.error(err); - } - _afterwards_(); - }); - } else { - _afterwards_(); - } - - function _afterwards_() { - // Don't actually write the directory if this is a dry run. - if (options.dry) { - return cb.success(); - } - - // Create the directory. - fs.mkdirs(rootPath, err => { - if (err) { - return cb.error(err); - } - return cb.success(); - }); - } - }); -}; diff --git a/packages/generators/generate/lib/helpers/jsonfile/index.js b/packages/generators/generate/lib/helpers/jsonfile/index.js deleted file mode 100644 index 1df9f1ef89..0000000000 --- a/packages/generators/generate/lib/helpers/jsonfile/index.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// Public node modules. -const _ = require('lodash'); -const fs = require('fs-extra'); -const reportback = require('reportback')(); - -/** - * Generate a JSON file - */ - -/* eslint-disable prefer-template */ -module.exports = function(options, handlers) { - // Provide default values for handlers. - handlers = reportback.extend(handlers, { - alreadyExists: 'error', - }); - - // Provide defaults and validate required options. - _.defaults(options, { - force: false, - }); - - const missingOpts = _.difference(['rootPath', 'data'], Object.keys(options)); - - if (missingOpts.length) { - return handlers.invalid(missingOpts); - } - - const rootPath = path.resolve(process.cwd(), options.rootPath); - - // Only override an existing file if `options.force` is true. - fs.exists(rootPath, exists => { - if (exists && !options.force) { - return handlers.alreadyExists('Something else already exists at `' + rootPath + '`.'); - } - - if (exists) { - fs.remove(rootPath, err => { - if (err) { - return handlers.error(err); - } - _afterwards_(); - }); - } else { - _afterwards_(); - } - - function _afterwards_() { - fs.outputJSON(rootPath, options.data, { spaces: 2 }, err => { - if (err) { - return handlers.error(err); - } else { - handlers.success(); - } - }); - } - }); -}; diff --git a/packages/generators/generate/lib/helpers/template/index.js b/packages/generators/generate/lib/helpers/template/index.js deleted file mode 100644 index 4cb7c03798..0000000000 --- a/packages/generators/generate/lib/helpers/template/index.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// Public node modules. -const _ = require('lodash'); -const fs = require('fs-extra'); -const reportback = require('reportback')(); - -// Local dependencies. -const fileHelper = require('../file'); - -/** - * Read a dynamic template, compile it using scope. - * Then use `file` helper to write it to its destination. - */ - -module.exports = function(options, cb) { - cb = reportback.extend(cb, { - noTemplate: 'error', - alreadyExists: 'error', - }); - - // Compute the canonical path to a template - // given its relative path from its source generator's - // `templates` directory. - if (_.isFunction(options.templatesDirectory)) { - options.templatesDirectory = options.templatesDirectory(options); - } - - const absTemplatePath = path.resolve(options.templatesDirectory, options.templatePath); - - fs.readFile(absTemplatePath, 'utf8', (err, contents) => { - if (err) { - err = err instanceof Error ? err : new Error(err); - err.message = `Template error: ${err.message}`; - err.path = absTemplatePath; - if (err.code === 'ENOENT') { - return cb.noTemplate(err); - } else { - return cb(err); - } - } - - try { - const compiled = _.template(contents, { - interpolate: /<%=([\s\S]+?)%>/g, - }); - contents = compiled(options); - - // With Lodash templates, HTML entities are escaped by default. - // Default assumption is we don't want that, so we'll reverse it. - if (!options.escapeHTMLEntities) { - contents = _.unescape(contents); - } - } catch (e) { - return cb(e); - } - - return fileHelper( - _.merge(options, { - contents, - }), - cb - ); - }); -}; diff --git a/packages/generators/generate/lib/index.js b/packages/generators/generate/lib/index.js deleted file mode 100644 index 8607e3c5cd..0000000000 --- a/packages/generators/generate/lib/index.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const reportback = require('reportback')(); - -// Logger. -const logger = require('@strapi/utils').logger; - -// Local dependencies. -const generate = require('./generate'); -const generateTarget = require('./target'); - -/* eslint-disable prefer-template */ -/** - * Generate module(s) - * - * @param {Object} scope - * @param {Function} cb - * - * @return {[Type]} - */ - -module.exports = (scope, cb) => { - cb = cb || {}; - cb = reportback.extend(cb, { - error: cb.error, - success: () => {}, - notStrapiApp: () => {}, - alreadyExists: () => { - return cb.error(); - }, - }); - - // Use configured module name for this `generatorType` if applicable. - const module = '@strapi/generate-' + scope.generatorType; - let generator; - - function throwIfModuleNotFoundError(error, module) { - const isModuleNotFoundError = - error && error.code === 'MODULE_NOT_FOUND' && error.message.match(new RegExp(module)); - if (!isModuleNotFoundError) { - logger.error('Invalid `' + scope.generatorType + '` generator.'); - throw error; - } else { - return error; - } - } - - // Try to require the module or throw if error. - try { - generator = require(module); - } catch (error) { - throwIfModuleNotFoundError(error, module); - } - - if (!generator) { - return logger.error('No generator called `' + scope.generatorType + '` found.'); - } - - generate(generator, scope, cb); -}; - -module.exports.generateTarget = generateTarget; diff --git a/packages/generators/generate/lib/target.js b/packages/generators/generate/lib/target.js deleted file mode 100644 index 57787462e0..0000000000 --- a/packages/generators/generate/lib/target.js +++ /dev/null @@ -1,318 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -/* eslint-disable prefer-template */ -// Node.js core. -const path = require('path'); -const util = require('util'); - -// Public node modules. -const _ = require('lodash'); -const async = require('async'); -const report = require('reportback')(); - -// Local dependencies. -const folderHelper = require('./helpers/folder'); -const templateHelper = require('./helpers/template'); -const jsonFileHelper = require('./helpers/jsonfile'); -const copyHelper = require('./helpers/copy'); - -/** - * generateTarget() - * - * @param {Object} options - */ - -function generateTarget(options, cb) { - const sb = report.extend(cb); - - // Options. - let target = options.target; - let scope = options.scope; - const parentGenerator = options.parent; - const recursiveGenerate = options.recursiveGenerate; - - const maxResolves = 5; - let _resolves = 0; - - async.until( - () => { - return isValidTarget(target) || ++_resolves > maxResolves; - }, - asyncCb => { - parseTarget(target, scope, (err, resolvedTarget) => { - if (err) { - return asyncCb(err); - } - target = resolvedTarget; - return asyncCb(); - }); - }, - err => { - if (err) { - return sb(err); - } - if (!isValidTarget(target)) { - return sb( - new Error( - 'Generator Error :: Could not resolve target `' + - scope.rootPath + - '` (probably a recursive loop)' - ) - ); - } - - // Pass down parent Generator's template directory abs path. - scope.templatesDirectory = parentGenerator.templatesDirectory; - - if (target.copy) { - scope = mergeSubtargetScope( - scope, - typeof target.copy === 'string' - ? { - templatePath: target.copy, - } - : target.copy - ); - return copyHelper(scope, sb); - } - - if (target.folder) { - scope = mergeSubtargetScope(scope, target.folder); - return folderHelper(scope, sb); - } - - if (target.template) { - scope = mergeSubtargetScope( - scope, - typeof target.template === 'string' - ? { - templatePath: target.template, - } - : target.template - ); - - return templateHelper(scope, sb); - } - - if (target.jsonfile) { - if (typeof target.jsonfile === 'object') { - scope = mergeSubtargetScope(scope, target.jsonfile); - } else if (typeof target.jsonfile === 'function') { - scope = _.merge(scope, { - data: target.jsonfile(scope), - }); - } - return jsonFileHelper(scope, sb); - } - - // If we made it here, this must be a recursive generator. - // Now that the generator definition has been resolved, - // call this method recursively on it, passing along our - // callback. - if (++scope._depth > scope.maxHops) { - return sb( - new Error( - '`maxHops` (' + - scope.maxHops + - ') exceeded! There is probably a recursive loop in one of your generators.' - ) - ); - } - return recursiveGenerate(target, scope, sb); - } - ); -} - -module.exports = generateTarget; - -/** - * @param {[Type]} scope Description - * @param {[Type]} subtarget Description - * @return {[Type]} Description - */ - -function mergeSubtargetScope(scope, subtarget) { - return _.merge(scope, _.isObject(subtarget) ? subtarget : {}); -} - -/** - * Known helpers - * - * @type {Array} - */ - -const knownHelpers = ['folder', 'template', 'jsonfile', 'file', 'copy']; - -function targetIsHelper(target) { - return _.some(target, (subTarget, key) => { - return _.includes(knownHelpers, key); - }); -} - -/** - * @param {String|Object} target Description - * @param {Object} scope Description - * @param {Function} cb Description - * @return {[type]} Description - */ - -function parseTarget(target, scope, cb) { - if (typeof target === 'string') { - target = { - generator: target, - }; - } - - // Interpret generator definition. - if (targetIsHelper(target)) { - return cb(null, target); - } - - if (target.generator) { - // Normalize the subgenerator reference. - let subGeneratorRef; - if (typeof target.generator === 'string') { - subGeneratorRef = { - module: target.generator, - }; - } else if (typeof target.generator === 'object') { - subGeneratorRef = target.generator; - } - - if (!subGeneratorRef) { - return cb( - new Error( - 'Generator Error :: Invalid subgenerator referenced for target `' + scope.rootPath + '`' - ) - ); - } - - // Now normalize the sub-generator. - let subGenerator; - - // No `module` means we'll treat this subgenerator as an inline generator definition. - if (!subGeneratorRef.module) { - subGenerator = subGeneratorRef; - if (subGenerator) { - return cb(null, subGenerator); - } - } - - // Otherwise, we'll attempt to load this subgenerator. - if (typeof subGeneratorRef.module === 'string') { - // Lookup the generator by name if a `module` was specified - // This allows the module for a given generator to be - // overridden. - const configuredReference = scope.modules && scope.modules[subGeneratorRef.module]; - - // Refers to a configured module. - // If this generator type is explicitly set to `false`, - // disable the generator. - if (configuredReference) { - return cb(null, configuredReference); - } else if (configuredReference === false) { - return cb(null); - } - - // If `configuredReference` is undefined, continue on - // and try to require the module. - } - - // At this point, `subGeneratorRef.module` should be a string, - // and the best guess at the generator module we're going - // to get. - const module = subGeneratorRef.module; - let requireError; - - // Try requiring it directly as a path. - try { - subGenerator = require(module); - } catch (e0) { - requireError = e0; - } - - // Try the scope's `rootPath`. - if (!subGenerator) { - try { - const asDependencyInRootPath = path.resolve(scope.rootPath, 'node_modules', module); - subGenerator = require(asDependencyInRootPath); - } catch (e1) { - requireError = e1; - } - } - - // Try the current working directory. - if (!subGenerator) { - try { - subGenerator = require(path.resolve(process.cwd(), 'node_modules', module)); - } catch (e1) { - requireError = e1; - } - } - - // If we couldn't find a generator using the configured module, - // try requiring `@strapi/generate-` to get the core generator. - if (!subGenerator && !module.match(/^@strapi\/generate-/)) { - try { - if (process.mainModule.filename.indexOf('yarn') !== -1) { - subGenerator = require(path.resolve( - process.mainModule.paths[2], - '@strapi/generate-' + module - )); - } else { - subGenerator = require(path.resolve( - process.mainModule.paths[1], - '@strapi/generate-' + module - )); - } - } catch (e1) { - requireError = e1; - } - } - - // If we were able to find it, send it back! - if (subGenerator) { - return cb(null, subGenerator); - } - - // But if we still can't find it, give up. - return cb( - new Error( - 'Error: Failed to load `' + - subGeneratorRef.module + - '`...' + - (requireError ? ' (' + requireError + ')' : '') + - '' - ) - ); - } - - return cb( - new Error( - 'Unrecognized generator syntax in `targets["' + - scope.keyPath + - '"]` ::\n' + - util.inspect(target) - ) - ); -} - -/** - * - * @param {[Type]} target Description - * @return {Boolean} Description - */ - -function isValidTarget(target) { - let ok = typeof target === 'object'; - - // Is using a helper. - // Or is another generator def. - ok = ok && (targetIsHelper(target) || _.has(target, 'targets')); - - return ok; -} diff --git a/packages/generators/generate/lib/util.js b/packages/generators/generate/lib/util.js deleted file mode 100644 index 0c1ac3468a..0000000000 --- a/packages/generators/generate/lib/util.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -/** - * From Express core: (MIT License) - * - * Normalize the given path string, - * returning a regular expression. - * - * An empty array should be passed, - * which will contain the placeholder - * key names. For example "/user/:id" will - * then contain ["id"]. - * - * @param {String|RegExp|Array} path - * @param {Array} keys - * @param {Boolean} sensitive - * @param {Boolean} strict - * @return {RegExp} - * @api private - */ - -/* eslint-disable prefer-template */ -/* eslint-disable no-useless-escape */ -const pathRegexp = (path, keys, sensitive, strict) => { - if (toString.call(path) === '[object RegExp]') { - return path; - } - if (Array.isArray(path)) { - path = '(' + path.join('|') + ')'; - } - path = path - .concat(strict ? '' : '/?') - .replace(/\/\(/g, '(?:/') - .replace( - /(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g, - (_, slash, format, key, capture, optional, star) => { - keys.push({ - name: key, - optional: !!optional, - }); - slash = slash || ''; - return ( - '' + - (optional ? '' : slash) + - '(?:' + - (optional ? slash : '') + - (format || '') + - (capture || (format && '([^/.]+?)') || '([^/]+?)') + - ')' + - (optional || '') + - (star ? '(/*)?' : '') - ); - } - ) - .replace(/([\/.])/g, '\\$1') - .replace(/\*/g, '(.*)'); - return new RegExp('^' + path + '$', sensitive ? '' : 'i'); -}; - -module.exports = { - pathRegexp, -}; diff --git a/packages/generators/generate/package.json b/packages/generators/generate/package.json deleted file mode 100644 index 72b9aa6bd4..0000000000 --- a/packages/generators/generate/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "@strapi/generate", - "version": "3.6.8", - "description": "Master of ceremonies for the Strapi generators.", - "homepage": "https://strapi.io", - "keywords": [ - "generate", - "generator", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "dependencies": { - "async": "^2.6.2", - "fs-extra": "^9.1.0", - "lodash": "4.17.21", - "reportback": "^2.0.2", - "@strapi/utils": "3.6.8" - }, - "author": { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/plugins/i18n/.editorconfig b/packages/generators/generators/.editorconfig similarity index 100% rename from packages/plugins/i18n/.editorconfig rename to packages/generators/generators/.editorconfig diff --git a/packages/plugins/i18n/.gitattributes b/packages/generators/generators/.gitattributes similarity index 100% rename from packages/plugins/i18n/.gitattributes rename to packages/generators/generators/.gitattributes diff --git a/packages/plugins/i18n/.gitignore b/packages/generators/generators/.gitignore similarity index 100% rename from packages/plugins/i18n/.gitignore rename to packages/generators/generators/.gitignore diff --git a/packages/generators/controller/.gitignore b/packages/generators/generators/.npmignore similarity index 96% rename from packages/generators/controller/.gitignore rename to packages/generators/generators/.npmignore index 47e0ea73cc..a788251bc6 100644 --- a/packages/generators/controller/.gitignore +++ b/packages/generators/generators/.npmignore @@ -67,7 +67,6 @@ $RECYCLE.BIN/ *.log *.sql -*.sqlite ############################ @@ -76,6 +75,8 @@ $RECYCLE.BIN/ *# ssl +.editorconfig +.gitattributes .idea nbproject @@ -89,16 +90,14 @@ lcov.info pids logs results -build node_modules .node_history -package-lock.json - ############################ # Tests ############################ +test testApp coverage diff --git a/packages/generators/generate/LICENSE b/packages/generators/generators/LICENSE similarity index 99% rename from packages/generators/generate/LICENSE rename to packages/generators/generators/LICENSE index db018546b5..638baf882b 100644 --- a/packages/generators/generate/LICENSE +++ b/packages/generators/generators/LICENSE @@ -19,4 +19,4 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/packages/generators/generators/README.md b/packages/generators/generators/README.md new file mode 100644 index 0000000000..ee26cbe562 --- /dev/null +++ b/packages/generators/generators/README.md @@ -0,0 +1,18 @@ +# @strapi/generators + +This package contains strapi code generators available through the CLI or programmatically. + +## API Reference + +### `runCLI()` + +Start the generator CLI. + +### `generate(generatorName, options, plopOptions)` + +Execute a generator without interactive mode. + +- `generatorName` - one of `api`, `controller`, `service`, `model`, `plugin`, `policy`. +- `options` - options are specific to each generator +- `plopOtions` + - `dir`: base directory that plop will use as base directory for its actions diff --git a/packages/generators/plugin/templates/editorconfig b/packages/generators/generators/lib/files/plugin/.editorconfig similarity index 100% rename from packages/generators/plugin/templates/editorconfig rename to packages/generators/generators/lib/files/plugin/.editorconfig diff --git a/packages/generators/plugin/templates/gitattributes b/packages/generators/generators/lib/files/plugin/.gitattributes similarity index 100% rename from packages/generators/plugin/templates/gitattributes rename to packages/generators/generators/lib/files/plugin/.gitattributes diff --git a/packages/generators/plugin/templates/gitignore b/packages/generators/generators/lib/files/plugin/.gitignore similarity index 100% rename from packages/generators/plugin/templates/gitignore rename to packages/generators/generators/lib/files/plugin/.gitignore diff --git a/packages/generators/plugin/files/admin/src/components/Initializer/index.js b/packages/generators/generators/lib/files/plugin/admin/src/components/Initializer/index.js similarity index 100% rename from packages/generators/plugin/files/admin/src/components/Initializer/index.js rename to packages/generators/generators/lib/files/plugin/admin/src/components/Initializer/index.js diff --git a/packages/generators/plugin/files/admin/src/pages/App/index.js b/packages/generators/generators/lib/files/plugin/admin/src/containers/App/index.js similarity index 100% rename from packages/generators/plugin/files/admin/src/pages/App/index.js rename to packages/generators/generators/lib/files/plugin/admin/src/containers/App/index.js diff --git a/packages/generators/plugin/files/admin/src/pages/HomePage/index.js b/packages/generators/generators/lib/files/plugin/admin/src/containers/HomePage/index.js similarity index 100% rename from packages/generators/plugin/files/admin/src/pages/HomePage/index.js rename to packages/generators/generators/lib/files/plugin/admin/src/containers/HomePage/index.js diff --git a/packages/generators/generators/lib/files/plugin/admin/src/containers/Initializer/index.js b/packages/generators/generators/lib/files/plugin/admin/src/containers/Initializer/index.js new file mode 100644 index 0000000000..71dc50e94c --- /dev/null +++ b/packages/generators/generators/lib/files/plugin/admin/src/containers/Initializer/index.js @@ -0,0 +1,26 @@ +/** + * + * Initializer + * + */ + +import { useEffect, useRef } from 'react'; +import PropTypes from 'prop-types'; +import pluginId from '../../pluginId'; + +const Initializer = ({ setPlugin }) => { + const ref = useRef(); + ref.current = setPlugin; + + useEffect(() => { + ref.current(pluginId); + }, []); + + return null; +}; + +Initializer.propTypes = { + setPlugin: PropTypes.func.isRequired, +}; + +export default Initializer; diff --git a/packages/generators/plugin/files/admin/src/index.js b/packages/generators/generators/lib/files/plugin/admin/src/index.js similarity index 99% rename from packages/generators/plugin/files/admin/src/index.js rename to packages/generators/generators/lib/files/plugin/admin/src/index.js index 964996781b..7f0a2e1df1 100644 --- a/packages/generators/plugin/files/admin/src/index.js +++ b/packages/generators/generators/lib/files/plugin/admin/src/index.js @@ -2,6 +2,7 @@ import { prefixPluginTranslations } from '@strapi/helper-plugin'; import pluginPkg from '../../package.json'; import pluginId from './pluginId'; import Initializer from './components/Initializer'; + const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; const icon = pluginPkg.strapi.icon; const name = pluginPkg.strapi.name; @@ -38,6 +39,7 @@ export default { name, }); }, + bootstrap(app) {}, async registerTrads({ locales }) { const importedTrads = await Promise.all( diff --git a/packages/generators/generators/lib/files/plugin/admin/src/pages/App/index.js b/packages/generators/generators/lib/files/plugin/admin/src/pages/App/index.js new file mode 100644 index 0000000000..b2d80ef744 --- /dev/null +++ b/packages/generators/generators/lib/files/plugin/admin/src/pages/App/index.js @@ -0,0 +1,25 @@ +/** + * + * This component is the skeleton around the actual pages, and should only + * contain code that should be seen on all pages. (e.g. navigation bar) + * + */ + +import React from 'react'; +import { Switch, Route } from 'react-router-dom'; +import { NotFound } from '@strapi/helper-plugin'; +import pluginId from '../../pluginId'; +import HomePage from '../HomePage'; + +const App = () => { + return ( +
+ + + + +
+ ); +}; + +export default App; diff --git a/packages/generators/generators/lib/files/plugin/admin/src/pages/HomePage/index.js b/packages/generators/generators/lib/files/plugin/admin/src/pages/HomePage/index.js new file mode 100644 index 0000000000..05c5a6a377 --- /dev/null +++ b/packages/generators/generators/lib/files/plugin/admin/src/pages/HomePage/index.js @@ -0,0 +1,20 @@ +/* + * + * HomePage + * + */ + +import React, { memo } from 'react'; +// import PropTypes from 'prop-types'; +import pluginId from '../../pluginId'; + +const HomePage = () => { + return ( +
+

{pluginId}'s HomePage

+

Happy coding

+
+ ); +}; + +export default memo(HomePage); diff --git a/packages/generators/plugin/files/admin/src/pluginId.js b/packages/generators/generators/lib/files/plugin/admin/src/pluginId.js similarity index 100% rename from packages/generators/plugin/files/admin/src/pluginId.js rename to packages/generators/generators/lib/files/plugin/admin/src/pluginId.js diff --git a/packages/generators/plugin/files/admin/src/translations/en.json b/packages/generators/generators/lib/files/plugin/admin/src/translations/en.json similarity index 100% rename from packages/generators/plugin/files/admin/src/translations/en.json rename to packages/generators/generators/lib/files/plugin/admin/src/translations/en.json diff --git a/packages/generators/plugin/files/admin/src/translations/fr.json b/packages/generators/generators/lib/files/plugin/admin/src/translations/fr.json similarity index 100% rename from packages/generators/plugin/files/admin/src/translations/fr.json rename to packages/generators/generators/lib/files/plugin/admin/src/translations/fr.json diff --git a/packages/generators/plugin/files/admin/src/utils/getTrad.js b/packages/generators/generators/lib/files/plugin/admin/src/utils/getTrad.js similarity index 100% rename from packages/generators/plugin/files/admin/src/utils/getTrad.js rename to packages/generators/generators/lib/files/plugin/admin/src/utils/getTrad.js diff --git a/packages/generators/generators/lib/index.js b/packages/generators/generators/lib/index.js new file mode 100644 index 0000000000..ce385d8b2e --- /dev/null +++ b/packages/generators/generators/lib/index.js @@ -0,0 +1,37 @@ +'use strict'; + +const { join } = require('path'); +const { Plop, run } = require('plop'); +const nodePlop = require('node-plop'); + +/** + * Starts the Plop CLI programmatically + */ +const runCLI = () => { + Plop.launch({ configPath: join(__dirname, 'plopfile.js') }, env => + run({ ...env, dest: process.cwd() }, undefined, true) + ); +}; + +/** + * Runs a generator programmatically without prompts + * @param {string} generatorName + * @param {Object} options generator options replacing the prompts answers + * @param {Object} plopOptions + * @param {string} plopOptions.dir base path for plop to generate the files from + */ +const generate = async (generatorName, options, { dir = process.cwd() } = {}) => { + const plop = nodePlop(join(__dirname, 'plopfile.js'), { destBasePath: dir }); + + const generator = plop.getGenerator(generatorName); + await generator.runActions(options, { + onSuccess: () => {}, + onFailure: () => {}, + onComment: () => {}, + }); +}; + +module.exports = { + generate, + runCLI, +}; diff --git a/packages/generators/generators/lib/plopfile.js b/packages/generators/generators/lib/plopfile.js new file mode 100644 index 0000000000..1825295d9c --- /dev/null +++ b/packages/generators/generators/lib/plopfile.js @@ -0,0 +1,24 @@ +'use strict'; + +const pluralize = require('pluralize'); + +const generateApi = require('./plops/api'); +const generateController = require('./plops/controller'); +const generateModel = require('./plops/model'); +const generatePlugin = require('./plops/plugin'); +const generatePolicy = require('./plops/policy'); +const generateService = require('./plops/service'); + +module.exports = plop => { + // Plop config + plop.setWelcomeMessage('Strapi Generators'); + plop.addHelper('pluralize', text => pluralize(text)); + + // Generators + generateApi(plop); + generateController(plop); + generateModel(plop); + generatePlugin(plop); + generatePolicy(plop); + generateService(plop); +}; diff --git a/packages/generators/generators/lib/plops/api.js b/packages/generators/generators/lib/plops/api.js new file mode 100644 index 0000000000..f15a6266a9 --- /dev/null +++ b/packages/generators/generators/lib/plops/api.js @@ -0,0 +1,112 @@ +'use strict'; + +const { join } = require('path'); +const fs = require('fs-extra'); +const validateInput = require('./utils/validate-input'); + +module.exports = plop => { + // API generator + plop.setGenerator('api', { + description: 'Generate a basic API', + prompts: [ + { + type: 'input', + name: 'id', + message: 'API name', + validate: input => validateInput(input), + }, + { + type: 'confirm', + name: 'isPluginApi', + message: 'Is this API for a plugin?', + }, + { + when: answers => answers.isPluginApi, + type: 'list', + name: 'plugin', + message: 'Plugin name', + choices: async () => { + const pluginsPath = join(plop.getDestBasePath(), 'plugins'); + const exists = await fs.pathExists(pluginsPath); + + if (!exists) { + throw Error('Couldn\'t find a "plugins" directory'); + } + + const pluginsDir = await fs.readdir(pluginsPath, { withFileTypes: true }); + const pluginsDirContent = pluginsDir.filter(fd => fd.isDirectory()); + + if (pluginsDirContent.length === 0) { + throw Error('The "plugins" directory is empty'); + } + + return pluginsDirContent; + }, + }, + { + type: 'list', + name: 'kind', + message: 'Please choose the model type', + default: 'collectionType', + choices: [ + { name: 'Collection Type', value: 'collectionType' }, + { name: 'Singe Type', value: 'singleType' }, + ], + }, + { + type: 'confirm', + name: 'useDraftAndPublish', + message: 'Use draft and publish?', + }, + ], + actions: answers => { + let filePath; + if (answers.isPluginApi && answers.plugin) { + filePath = `plugins/{{plugin}}`; + } else { + filePath = `api/{{id}}`; + } + + const baseActions = [ + { + type: 'add', + path: `${filePath}/controllers/{{id}}.js`, + templateFile: 'templates/controller.js.hbs', + }, + { + type: 'add', + path: `${filePath}/models/{{id}}.js`, + templateFile: 'templates/model.js.hbs', + }, + { + type: 'add', + path: `${filePath}/models/{{id}}.settings.json`, + templateFile: 'templates/model.settings.json.hbs', + }, + { + type: 'add', + path: `${filePath}/services/{{id}}.js`, + templateFile: 'templates/service.js.hbs', + }, + ]; + + if (answers.isPluginApi) { + return baseActions; + } else { + const routeType = + answers.kind === 'singleType' + ? 'single-type-routes.json.hbs' + : 'collection-type-routes.json.hbs'; + + return [ + { + type: 'add', + path: `${filePath}/config/routes.json`, + templateFile: `templates/${routeType}`, + }, + ...baseActions, + ]; + } + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/controller.js b/packages/generators/generators/lib/plops/controller.js new file mode 100644 index 0000000000..f58d484de1 --- /dev/null +++ b/packages/generators/generators/lib/plops/controller.js @@ -0,0 +1,32 @@ +'use strict'; + +const getDestinationPrompts = require('./utils/get-destination-prompts'); +const getFilePath = require('./utils/get-file-path'); +const validateInput = require('./utils/validate-input'); + +module.exports = plop => { + // Controller generator + plop.setGenerator('controller', { + description: 'Generate a controller for an API', + prompts: [ + { + type: 'input', + name: 'id', + message: 'Controller name', + validate: input => validateInput(input), + }, + ...getDestinationPrompts('controller', plop.getDestBasePath()), + ], + actions: answers => { + const filePath = getFilePath(answers.destination); + + return [ + { + type: 'add', + path: `${filePath}/controllers/{{id}}.js`, + templateFile: 'templates/controller.js.hbs', + }, + ]; + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/model.js b/packages/generators/generators/lib/plops/model.js new file mode 100644 index 0000000000..9497688fda --- /dev/null +++ b/packages/generators/generators/lib/plops/model.js @@ -0,0 +1,177 @@ +'use strict'; + +const getDestinationPrompts = require('./utils/get-destination-prompts'); +const getFilePath = require('./utils/get-file-path'); +const validateInput = require('./utils/validate-input'); + +const DEFAULT_TYPES = [ + // advanced types + 'media', + + // scalar types + 'string', + 'text', + 'richtext', + 'json', + 'enumeration', + 'password', + 'email', + 'integer', + 'biginteger', + 'float', + 'decimal', + 'date', + 'time', + 'datetime', + 'timestamp', + 'boolean', +]; + +const promptConfigQuestions = (plop, inquirer) => { + return inquirer.prompt([ + { + type: 'input', + name: 'id', + message: 'Model name', + validate: input => validateInput(input), + }, + { + type: 'list', + name: 'kind', + message: 'Please choose the model type', + choices: [ + { name: 'Collection Type', value: 'collectionType' }, + { name: 'Singe Type', value: 'singleType' }, + ], + validate: input => validateInput(input), + }, + ...getDestinationPrompts('model', plop.getDestBasePath()), + { + type: 'confirm', + name: 'useDraftAndPublish', + message: 'Use draft and publish?', + }, + { + type: 'confirm', + name: 'addAttributes', + message: 'Do you want to add attributes?', + }, + ]); +}; + +const promptAttributeQuestions = inquirer => { + return inquirer.prompt([ + { + type: 'input', + name: 'attributeName', + message: 'Name of attribute', + validate: input => validateInput(input), + }, + { + type: 'list', + name: 'attributeType', + message: 'What type of attribute', + pageSize: DEFAULT_TYPES.length, + choices: DEFAULT_TYPES.map(type => { + return { name: type, value: type }; + }), + }, + { + when: answers => answers.attributeType === 'enumeration', + type: 'input', + name: 'enum', + message: 'Add values separated by a comma', + }, + { + when: answers => answers.attributeType === 'media', + type: 'list', + name: 'multiple', + message: 'Choose media type', + choices: [ + { name: 'Multiple', value: true }, + { name: 'Single', value: false }, + ], + }, + { + type: 'confirm', + name: 'addAttributes', + message: 'Do you want to add another attribute?', + }, + ]); +}; + +module.exports = plop => { + // Model generator + plop.setGenerator('model', { + description: 'Generate a model for an API', + prompts: async inquirer => { + const config = await promptConfigQuestions(plop, inquirer); + + if (!config.addAttributes) { + return { + ...config, + attributes: [], + }; + } + + const attributes = []; + + const genAttribute = async () => { + const answers = await promptAttributeQuestions(inquirer); + + attributes.push(answers); + + if (answers.addAttributes) { + return genAttribute(); + } + }; + + await genAttribute(); + + return { + ...config, + attributes, + }; + }, + actions: answers => { + const attributes = answers.attributes.reduce((object, answer) => { + const val = { type: answer.attributeType }; + + if (answer.attributeType === 'enumeration') { + val.enum = answer.enum.split(',').map(item => item.trim()); + } + + if (answer.attributeType === 'media') { + val.allowedTypes = ['images', 'files', 'videos']; + val.multiple = answer.multiple; + } + + return Object.assign(object, { [answer.attributeName]: val }, {}); + }, {}); + + const filePath = getFilePath(answers.destination); + + return [ + { + type: 'add', + path: `${filePath}/models/{{id}}.js`, + templateFile: 'templates/model.js.hbs', + }, + { + type: 'add', + path: `${filePath}/models/{{id}}.settings.json`, + templateFile: 'templates/model.settings.json.hbs', + }, + { + type: 'modify', + path: `${filePath}/models/{{id}}.settings.json`, + transform: template => { + const parsedTemplate = JSON.parse(template); + parsedTemplate.attributes = attributes; + return JSON.stringify(parsedTemplate, null, 2); + }, + }, + ]; + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/plugin.js b/packages/generators/generators/lib/plops/plugin.js new file mode 100644 index 0000000000..e5bdf96206 --- /dev/null +++ b/packages/generators/generators/lib/plops/plugin.js @@ -0,0 +1,50 @@ +'use strict'; + +module.exports = plop => { + // Plugin generator + plop.setGenerator('plugin', { + description: 'Generate a basic plugin', + prompts: [ + { + type: 'input', + name: 'id', + message: 'Plugin name', + }, + ], + actions: () => { + return [ + { + type: 'addMany', + destination: 'plugins/{{id}}/admin', + base: 'files/plugin/admin', + templateFiles: 'files/plugin/admin/**', + }, + { + type: 'add', + path: 'plugins/{{id}}/services/{{id}}.js', + templateFile: 'templates/service.js.hbs', + }, + { + type: 'add', + path: 'plugins/{{id}}/controllers/{{id}}.js', + templateFile: 'templates/controller.js.hbs', + }, + { + type: 'add', + path: 'plugins/{{id}}/config/routes.json', + templateFile: 'templates/plugin-routes.json.hbs', + }, + { + type: 'add', + path: 'plugins/{{id}}/README.md', + templateFile: 'templates/README.md.hbs', + }, + { + type: 'add', + path: 'plugins/{{id}}/package.json', + templateFile: 'templates/plugin-package.json.hbs', + }, + ]; + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/policy.js b/packages/generators/generators/lib/plops/policy.js new file mode 100644 index 0000000000..6199201fde --- /dev/null +++ b/packages/generators/generators/lib/plops/policy.js @@ -0,0 +1,36 @@ +'use strict'; + +const getDestinationPrompts = require('./utils/get-destination-prompts'); + +module.exports = plop => { + // Policy generator + plop.setGenerator('policy', { + description: 'Generate a policy for an API', + prompts: [ + { + type: 'input', + name: 'id', + message: 'Policy name', + }, + ...getDestinationPrompts('policy', plop.getDestBasePath()), + ], + actions: answers => { + let filePath; + if (answers.destination === 'api') { + filePath = `api/{{api}}`; + } else if (answers.destination === 'plugin') { + filePath = `plugins/{{plugin}}`; + } else { + filePath = `./`; + } + + return [ + { + type: 'add', + path: `${filePath}/config/policies/{{id}}.js`, + templateFile: 'templates/policy.js.hbs', + }, + ]; + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/service.js b/packages/generators/generators/lib/plops/service.js new file mode 100644 index 0000000000..48fcbb7ee7 --- /dev/null +++ b/packages/generators/generators/lib/plops/service.js @@ -0,0 +1,29 @@ +'use strict'; + +const getDestinationPrompts = require('./utils/get-destination-prompts'); +const getFilePath = require('./utils/get-file-path'); + +module.exports = plop => { + // Service generator + plop.setGenerator('service', { + description: 'Generate a service for an API', + prompts: [ + { + type: 'input', + name: 'id', + message: 'Service name', + }, + ...getDestinationPrompts('service', plop.getDestBasePath()), + ], + actions: answers => { + const filePath = getFilePath(answers.destination); + return [ + { + type: 'add', + path: `${filePath}/services/{{id}}.js`, + templateFile: 'templates/service.js.hbs', + }, + ]; + }, + }); +}; diff --git a/packages/generators/generators/lib/plops/utils/get-destination-prompts.js b/packages/generators/generators/lib/plops/utils/get-destination-prompts.js new file mode 100644 index 0000000000..e117f119cf --- /dev/null +++ b/packages/generators/generators/lib/plops/utils/get-destination-prompts.js @@ -0,0 +1,69 @@ +'use strict'; +const { join } = require('path'); +const fs = require('fs-extra'); + +module.exports = (action, basePath) => { + return [ + { + type: 'list', + name: 'destination', + message: `Where do you want to add this ${action}?`, + choices: [ + { + name: `Add ${action} to ${action === 'policy' ? 'root of project' : 'new API'}`, + value: 'new', + }, + { name: `Add ${action} to an existing API`, value: 'api' }, + { name: `Add ${action} to an existing plugin`, value: 'plugin' }, + ], + }, + { + when: answers => answers.destination === 'api', + type: 'list', + message: 'Which API is this for?', + name: 'api', + choices: async () => { + const apiPath = join(basePath, 'api'); + const exists = await fs.pathExists(apiPath); + + if (!exists) { + throw Error('Couldn\'t find an "api" directory'); + } + + const apiDir = await fs.readdir(apiPath, { withFileTypes: true }); + const apiDirContent = apiDir.filter(fd => fd.isDirectory()); + + if (apiDirContent.length === 0) { + throw Error('The "api" directory is empty'); + } + + return apiDirContent; + }, + }, + { + when: answers => answers.destination === 'plugin', + type: 'list', + message: 'Which plugin is this for?', + name: 'plugin', + choices: async () => { + const pluginsPath = join(basePath, 'plugins'); + const exists = await fs.pathExists(pluginsPath); + + if (!exists) { + throw Error('Couldn\'t find a "plugins" directory'); + } + + const pluginsDir = await fs.readdir(pluginsPath); + const pluginsDirContent = pluginsDir.filter(api => + fs.lstatSync(join(pluginsPath, api)).isDirectory() + ); + + if (pluginsDirContent.length === 0) { + throw Error('The "plugins" directory is empty'); + } + + return pluginsDirContent; + }, + }, + ]; +}; diff --git a/packages/generators/generators/lib/plops/utils/get-file-path.js b/packages/generators/generators/lib/plops/utils/get-file-path.js new file mode 100644 index 0000000000..9e5775f1c4 --- /dev/null +++ b/packages/generators/generators/lib/plops/utils/get-file-path.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = destination => { + if (destination === 'api') { + return `api/{{api}}`; + } + + if (destination === 'plugin') { + return `plugins/{{plugin}}`; + } + + return `api/{{id}}`; +}; diff --git a/packages/generators/generators/lib/plops/utils/validate-input.js b/packages/generators/generators/lib/plops/utils/validate-input.js new file mode 100644 index 0000000000..e7e9076ec3 --- /dev/null +++ b/packages/generators/generators/lib/plops/utils/validate-input.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = input => { + const regex = /^[A-Za-z-]+$/g; + + if (!input) { + return 'You must provide an input'; + } + + return regex.test(input) || 'Please use only letters and no spaces'; +}; diff --git a/packages/generators/generators/lib/templates/README.md.hbs b/packages/generators/generators/lib/templates/README.md.hbs new file mode 100644 index 0000000000..c0073e2006 --- /dev/null +++ b/packages/generators/generators/lib/templates/README.md.hbs @@ -0,0 +1,3 @@ +# Strapi plugin {{id}} + +A quick description of {{id}}. diff --git a/packages/generators/generators/lib/templates/collection-type-routes.json.hbs b/packages/generators/generators/lib/templates/collection-type-routes.json.hbs new file mode 100644 index 0000000000..f5c6b78c71 --- /dev/null +++ b/packages/generators/generators/lib/templates/collection-type-routes.json.hbs @@ -0,0 +1,44 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/{{pluralize id}}", + "handler": "{{id}}.find", + "config": { + "policies": [] + } + }, + { + "method": "GET", + "path": "/{{pluralize id}}/:id", + "handler": "{{id}}.findOne", + "config": { + "policies": [] + } + }, + { + "method": "POST", + "path": "/{{pluralize id}}", + "handler": "{{id}}.create", + "config": { + "policies": [] + } + }, + { + "method": "PUT", + "path": "/{{pluralize id}}/:id", + "handler": "{{id}}.update", + "config": { + "policies": [] + } + }, + { + "method": "DELETE", + "path": "/{{pluralize id}}/:id", + "handler": "{{id}}.delete", + "config": { + "policies": [] + } + } + ] +} diff --git a/packages/generators/controller/templates/controller.template b/packages/generators/generators/lib/templates/controller.js.hbs similarity index 77% rename from packages/generators/controller/templates/controller.template rename to packages/generators/generators/lib/templates/controller.js.hbs index 929ca9ff11..e8d1615d32 100644 --- a/packages/generators/controller/templates/controller.template +++ b/packages/generators/generators/lib/templates/controller.js.hbs @@ -1,7 +1,7 @@ 'use strict'; /** - * A set of functions called "actions" for `<%= name %>` + * A set of functions called "actions" for `{{id}}` */ module.exports = { diff --git a/packages/generators/model/templates/model.template b/packages/generators/generators/lib/templates/model.js.hbs similarity index 100% rename from packages/generators/model/templates/model.template rename to packages/generators/generators/lib/templates/model.js.hbs diff --git a/packages/generators/generators/lib/templates/model.settings.json.hbs b/packages/generators/generators/lib/templates/model.settings.json.hbs new file mode 100644 index 0000000000..35ed2fad62 --- /dev/null +++ b/packages/generators/generators/lib/templates/model.settings.json.hbs @@ -0,0 +1,13 @@ + +{ + "kind": "{{kind}}", + "collectionName": "{{id}}", + "info": { + "name": "{{id}}" + }, + "options": { + "draftAndPublish": {{useDraftAndPublish}}, + "comment": "" + }, + "attributes": {} +} diff --git a/packages/generators/generators/lib/templates/plugin-package.json.hbs b/packages/generators/generators/lib/templates/plugin-package.json.hbs new file mode 100644 index 0000000000..82e2b16189 --- /dev/null +++ b/packages/generators/generators/lib/templates/plugin-package.json.hbs @@ -0,0 +1,28 @@ +{ + "name": "strapi-plugin-{{id}}", + "version": "0.0.0", + "description": "This is the description of the plugin.", + "strapi": { + "name": "{{id}}", + "icon": "plug", + "description": "Description of {{id}} plugin." + }, + "dependencies": {}, + "author": { + "name": "A Strapi developer", + "email": "", + "url": "" + }, + "maintainers": [ + { + "name": "A Strapi developer", + "email": "", + "url": "" + } + ], + "engines": { + "node": ">=12.x. <=16.x.x", + "npm": ">=6.0.0" + }, + "license": "MIT" +} diff --git a/packages/generators/generators/lib/templates/plugin-routes.json.hbs b/packages/generators/generators/lib/templates/plugin-routes.json.hbs new file mode 100644 index 0000000000..1de66cd215 --- /dev/null +++ b/packages/generators/generators/lib/templates/plugin-routes.json.hbs @@ -0,0 +1,12 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/", + "handler": "{{id}}.index", + "config": { + "policies": [] + } + } + ] +} \ No newline at end of file diff --git a/packages/generators/policy/templates/policy.template b/packages/generators/generators/lib/templates/policy.js.hbs similarity index 64% rename from packages/generators/policy/templates/policy.template rename to packages/generators/generators/lib/templates/policy.js.hbs index 0cf499a133..ae641e82d1 100644 --- a/packages/generators/policy/templates/policy.template +++ b/packages/generators/generators/lib/templates/policy.js.hbs @@ -1,12 +1,12 @@ 'use strict'; /** - * `<%= id %>` policy. + * `{{id}}` policy. */ module.exports = async (ctx, next) => { // Add your own logic here. - console.log('In <%= id %> policy.'); + console.log('In {{id}} policy.'); await next(); }; diff --git a/packages/generators/generators/lib/templates/service.js.hbs b/packages/generators/generators/lib/templates/service.js.hbs new file mode 100644 index 0000000000..bc8345530c --- /dev/null +++ b/packages/generators/generators/lib/templates/service.js.hbs @@ -0,0 +1,7 @@ +'use strict'; + +/** + * {{id}} service. + */ + +module.exports = {}; diff --git a/packages/generators/generators/lib/templates/single-type-routes.json.hbs b/packages/generators/generators/lib/templates/single-type-routes.json.hbs new file mode 100644 index 0000000000..9f1a110ce3 --- /dev/null +++ b/packages/generators/generators/lib/templates/single-type-routes.json.hbs @@ -0,0 +1,28 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/{{id}}", + "handler": "{{id}}.find", + "config": { + "policies": [] + } + }, + { + "method": "PUT", + "path": "/{{id}}", + "handler": "{{id}}.update", + "config": { + "policies": [] + } + }, + { + "method": "DELETE", + "path": "/{{id}}/", + "handler": "{{id}}.delete", + "config": { + "policies": [] + } + } + ] +} diff --git a/packages/generators/policy/package.json b/packages/generators/generators/package.json similarity index 60% rename from packages/generators/policy/package.json rename to packages/generators/generators/package.json index e4cfa63b2c..f4486908c1 100644 --- a/packages/generators/policy/package.json +++ b/packages/generators/generators/package.json @@ -1,28 +1,23 @@ { - "name": "@strapi/generate-policy", + "name": "@strapi/generators", "version": "3.6.8", - "description": "Generate a policy for a Strapi API.", - "homepage": "https://strapi.io", + "description": "Interactive API generator.", "keywords": [ - "generate", - "generator", - "policy", - "strapi" + "strapi", + "generators" ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" + "homepage": "https://strapi.io", + "bugs": { + "url": "https://github.com/strapi/strapi/issues" }, - "dependencies": { - "lodash": "4.17.21", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" + "repository": { + "type": "git", + "url": "git://github.com/strapi/strapi.git" }, + "license": "SEE LICENSE IN LICENSE", "author": { - "email": "hi@strapi.io", "name": "Strapi team", + "email": "hi@strapi.io", "url": "https://strapi.io" }, "maintainers": [ @@ -32,17 +27,15 @@ "url": "https://strapi.io" } ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" + "main": "lib/index.js", + "dependencies": { + "fs-extra": "10.0.0", + "node-plop": "0.26.2", + "plop": "2.7.4", + "pluralize": "8.0.0" }, "engines": { "node": ">=12.x.x <=16.x.x", "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" + } } diff --git a/packages/generators/model/.editorconfig b/packages/generators/model/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/model/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/model/.gitignore b/packages/generators/model/.gitignore deleted file mode 100644 index 47e0ea73cc..0000000000 --- a/packages/generators/model/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - - - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/model/.npmignore b/packages/generators/model/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/model/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/model/.snyk b/packages/generators/model/.snyk deleted file mode 100644 index c9ec6ce334..0000000000 --- a/packages/generators/model/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:35:59.679Z -patch: {} diff --git a/packages/generators/model/LICENSE b/packages/generators/model/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/model/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/model/README.md b/packages/generators/model/README.md deleted file mode 100644 index 39a36505b7..0000000000 --- a/packages/generators/model/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# strapi-generate-model - -[![npm version](https://img.shields.io/npm/v/strapi-generate-model.svg)](https://www.npmjs.org/package/strapi-generate-model) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-model.svg)](https://www.npmjs.org/package/strapi-generate-model) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-model.svg)](https://david-dm.org/strapi/strapi-generate-model) -[![Build status](https://travis-ci.org/strapi/strapi-generate-model.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-model) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains the default files for a model. - -This generator can be called with: - -```bash -$ strapi generate:model modelName apiName -``` - -For example if you want to generate a `group` model for the `user` API: - -```bash -$ strapi generate:model group user -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/model/lib/before.js b/packages/generators/model/lib/before.js deleted file mode 100644 index e169804b8c..0000000000 --- a/packages/generators/model/lib/before.js +++ /dev/null @@ -1,139 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); -const pluralize = require('pluralize'); -const { nameToSlug, nameToCollectionName } = require('@strapi/utils'); - -/* eslint-disable prefer-template */ - -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid( - 'Usage: `$ strapi generate:model modelName --api apiName --plugin pluginName`' - ); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - // `scope.args` are the raw command line arguments. - _.defaults(scope, { - name, - environment: process.env.NODE_ENV || 'development', - }); - - // Determine the destination path. - let filePath; - if (scope.args.api) { - filePath = `./api/${scope.args.api}/models`; - } else if (scope.args.plugin) { - filePath = `./plugins/${scope.args.plugin}/models`; - } else { - filePath = `./api/${name}/models`; - } - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - rootPath: scope.rootPath, - filePath, - filename: `${name}.js`, - filenameSettings: `${name}.settings.json`, - }); - - // Validate optional attribute arguments. - const invalidAttributes = []; - - if (_.isPlainObject(scope.args.attributes)) { - scope.attributes = scope.args.attributes; - } else { - // Map attributes and split them for CLI. - scope.attributes = scope.args.attributes.map(attribute => { - if (_.isString(attribute)) { - const parts = attribute.split(':'); - - parts[1] = parts[1] || 'string'; - - // Handle invalid attributes. - if (!parts[1] || !parts[0]) { - invalidAttributes.push('Error: Invalid attribute notation `' + attribute + '`.'); - return; - } - - return { - name: _.trim(_.deburr(parts[0].toLowerCase())), - params: { - type: _.trim(_.deburr(parts[1].toLowerCase())), - }, - }; - } else { - return _.has(attribute, 'params.type') ? attribute : undefined; - } - }); - - scope.attributes = _.compact(scope.attributes); - - // Handle invalid action arguments. - // Send back invalidActions. - if (invalidAttributes.length) { - return cb.invalid(invalidAttributes); - } - - // Make sure there aren't duplicates. - if ( - _(scope.attributes.map(attribute => attribute.name)) - .uniq() - .valueOf().length !== scope.attributes.length - ) { - return cb.invalid('Duplicate attributes not allowed!'); - } - - // Render some stringified code from the action template - // and make it available in our scope for use later on. - scope.attributes = scope.attributes.reduce((acc, attribute) => { - acc[attribute.name] = attribute.params; - return acc; - }, {}); - } - - // Set collectionName - scope.collectionName = _.has(scope.args, 'collectionName') - ? scope.args.collectionName - : nameToCollectionName(pluralize(scope.id)); - - // Set description - scope.description = _.has(scope.args, 'description') ? scope.args.description : undefined; - - scope.schema = JSON.stringify( - { - kind: 'collectionType', - collectionName: scope.collectionName, - info: { - name: scope.id, - description: scope.description, - }, - options: { - draftAndPublish: scope.args.draftAndPublish === 'true', - comment: '', - }, - attributes: scope.attributes, - }, - null, - 2 - ); - - // Trigger callback with no error to proceed. - return cb(); -}; diff --git a/packages/generators/model/lib/index.js b/packages/generators/model/lib/index.js deleted file mode 100644 index 1c2a0ef626..0000000000 --- a/packages/generators/model/lib/index.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - ':filePath/:filename': { - template: 'model.template', - }, - ':filePath/:filenameSettings': { - template: 'model.settings.template', - }, - }, -}; diff --git a/packages/generators/model/package.json b/packages/generators/model/package.json deleted file mode 100644 index d70f9a526b..0000000000 --- a/packages/generators/model/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@strapi/generate-model", - "version": "3.6.8", - "description": "Generate a model for a Strapi API.", - "homepage": "https://strapi.io", - "keywords": [ - "generate", - "generator", - "model", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "dependencies": { - "lodash": "4.17.21", - "pluralize": "^8.0.0", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "author": { - "email": "hi@strapi.io", - "name": "Strapi team", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/generators/model/templates/model.settings.template b/packages/generators/model/templates/model.settings.template deleted file mode 100644 index ae62b4b5c5..0000000000 --- a/packages/generators/model/templates/model.settings.template +++ /dev/null @@ -1 +0,0 @@ -<%= schema %> diff --git a/packages/generators/plugin/.editorconfig b/packages/generators/plugin/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/plugin/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/plugin/.gitignore b/packages/generators/plugin/.gitignore deleted file mode 100644 index 47e0ea73cc..0000000000 --- a/packages/generators/plugin/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - - - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/plugin/.npmignore b/packages/generators/plugin/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/plugin/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/plugin/.snyk b/packages/generators/plugin/.snyk deleted file mode 100644 index 49d166c9c1..0000000000 --- a/packages/generators/plugin/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:36:06.569Z -patch: {} diff --git a/packages/generators/plugin/LICENSE b/packages/generators/plugin/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/plugin/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/plugin/README.md b/packages/generators/plugin/README.md deleted file mode 100644 index 08dbf84cc7..0000000000 --- a/packages/generators/plugin/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# strapi-generate-plugin - -[![npm version](https://img.shields.io/npm/v/strapi-generate-plugin.svg)](https://www.npmjs.org/package/strapi-generate-plugin) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-plugin.svg)](https://www.npmjs.org/package/strapi-generate-plugin) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-plugin.svg)](https://david-dm.org/strapi/strapi-generate-plugin) -[![Build status](https://travis-ci.org/strapi/strapi-generate-plugin.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-plugin) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains all the default files for a new plugin. - -This generator can be called with: - -```bash -$ strapi generate:plugin pluginName -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/plugin/json/package.json.js b/packages/generators/plugin/json/package.json.js deleted file mode 100644 index 5513e29777..0000000000 --- a/packages/generators/plugin/json/package.json.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); - -/** - * Expose main package JSON of the application - * with basic info, dependencies, etc. - */ - -module.exports = scope => { - // Finally, return the JSON. - return _.merge(scope.appPackageJSON || {}, { - name: `strapi-plugin-${scope.id}`, - version: '0.0.0', - description: 'This is the description of the plugin.', - strapi: { - name: scope.id, - icon: 'plug', - description: `Description of ${scope.id} plugin.`, - }, - dependencies: {}, - author: { - name: scope.author || 'A Strapi developer', - email: scope.email || '', - url: scope.website || '', - }, - maintainers: [ - { - name: scope.author || 'A Strapi developer', - email: scope.email || '', - url: scope.website || '', - }, - ], - engines: { - node: '>=12.x. <=14.x.x', - npm: '>=6.0.0', - }, - license: scope.license || 'MIT', - }); -}; diff --git a/packages/generators/plugin/json/routes.json.js b/packages/generators/plugin/json/routes.json.js deleted file mode 100644 index 5456426c81..0000000000 --- a/packages/generators/plugin/json/routes.json.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -/** - * Expose main routes of the generated plugin - */ - -module.exports = scope => { - function generateRoutes() { - return { - routes: [ - { - method: 'GET', - path: '/', - handler: scope.name + '.index', - config: { - policies: [], - }, - }, - ], - }; - } - - return generateRoutes(); -}; diff --git a/packages/generators/plugin/lib/before.js b/packages/generators/plugin/lib/before.js deleted file mode 100644 index 7a922ca08c..0000000000 --- a/packages/generators/plugin/lib/before.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const path = require('path'); -const fs = require('fs-extra'); -const _ = require('lodash'); -const { nameToSlug } = require('@strapi/utils'); - -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid('Usage: `$ strapi generate:plugin pluginName`'); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - // Plugin info. - _.defaults(scope, { - name, - author: scope.author || 'A Strapi developer', - email: scope.email || '', - year: new Date().getFullYear(), - license: 'MIT', - }); - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - filename: `${name}.js`, - filePath: './plugins', - }); - - const pluginDir = path.resolve(scope.rootPath, 'plugins'); - fs.ensureDirSync(pluginDir); - - // Copy the admin files. - fs.copySync(path.resolve(__dirname, '..', 'files'), path.resolve(pluginDir, name)); - - // Trigger callback with no error to proceed. - return cb.success(); -}; diff --git a/packages/generators/plugin/lib/index.js b/packages/generators/plugin/lib/index.js deleted file mode 100644 index c804258860..0000000000 --- a/packages/generators/plugin/lib/index.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -// FIXME -/* eslint-disable import/extensions */ -// Local dependencies. -const packageJSON = require('../json/package.json.js'); -const routesJSON = require('../json/routes.json.js'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - 'plugins/:name/.gitignore': { - copy: 'gitignore', - }, - - // Use the default `controller` file as a template for - // every generated controller. - 'plugins/:name/controllers/:filename': { - template: 'controller.template', - }, - - // every generated controller. - 'plugins/:name/services/:filename': { - template: 'service.template', - }, - - // Generate routes. - 'plugins/:name/config/routes.json': { - jsonfile: routesJSON, - }, - - // Main package. - 'plugins/:name/package.json': { - jsonfile: packageJSON, - }, - - // Copy dot files. - 'plugins/:name/.editorconfig': { - copy: 'editorconfig', - }, - - 'plugins/:name/.gitattributes': { - copy: 'gitattributes', - }, - - // Copy Markdown files with some information. - 'plugins/:name/README.md': { - template: 'README.md', - }, - }, -}; diff --git a/packages/generators/plugin/package.json b/packages/generators/plugin/package.json deleted file mode 100644 index 9c5f8b5f27..0000000000 --- a/packages/generators/plugin/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@strapi/generate-plugin", - "version": "3.6.8", - "description": "Generate an plugin for a Strapi application.", - "homepage": "https://strapi.io", - "keywords": [ - "generate", - "generator", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "dependencies": { - "fs-extra": "^9.1.0", - "lodash": "4.17.21", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "author": { - "email": "hi@strapi.io", - "name": "Strapi team", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/generators/plugin/templates/README.md b/packages/generators/plugin/templates/README.md deleted file mode 100644 index 324fe31e64..0000000000 --- a/packages/generators/plugin/templates/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Strapi plugin <%= id %> - -A quick description of <%= id %>. diff --git a/packages/generators/plugin/templates/controller.template b/packages/generators/plugin/templates/controller.template deleted file mode 100644 index 6d32cf8c7f..0000000000 --- a/packages/generators/plugin/templates/controller.template +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -/** - * <%= filename %> controller - * - * @description: A set of functions called "actions" of the `<%= name %>` plugin. - */ - -module.exports = { - - /** - * Default action. - * - * @return {Object} - */ - - index: async (ctx) => { - // Add your own logic here. - - // Send 200 `ok` - ctx.send({ - message: 'ok' - }); - } -}; diff --git a/packages/generators/plugin/templates/service.template b/packages/generators/plugin/templates/service.template deleted file mode 100644 index 5891b61a5a..0000000000 --- a/packages/generators/plugin/templates/service.template +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -/** - * <%= filename %> service - * - * @description: A set of functions similar to controller's actions to avoid code duplication. - */ - -module.exports = { - -}; diff --git a/packages/generators/policy/.editorconfig b/packages/generators/policy/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/policy/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/policy/.gitignore b/packages/generators/policy/.gitignore deleted file mode 100644 index 47e0ea73cc..0000000000 --- a/packages/generators/policy/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - - - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/policy/.npmignore b/packages/generators/policy/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/policy/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/policy/.snyk b/packages/generators/policy/.snyk deleted file mode 100644 index 2d38b73373..0000000000 --- a/packages/generators/policy/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:36:09.263Z -patch: {} diff --git a/packages/generators/policy/LICENSE b/packages/generators/policy/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/policy/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/policy/README.md b/packages/generators/policy/README.md deleted file mode 100644 index d538dd3265..0000000000 --- a/packages/generators/policy/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# strapi-generate-policy - -[![npm version](https://img.shields.io/npm/v/strapi-generate-policy.svg)](https://www.npmjs.org/package/strapi-generate-policy) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-policy.svg)](https://www.npmjs.org/package/strapi-generate-policy) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-policy.svg)](https://david-dm.org/strapi/strapi-generate-policy) -[![Build status](https://travis-ci.org/strapi/strapi-generate-policy.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-policy) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains the default files for a policy. - -This generator can be called with: - -```bash -$ strapi generate:policy policyName apiName -``` - -For example if you want to generate a `isAuthenticated` policy for the `user` API: - -```bash -$ strapi generate:policy isAuthenticated user -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/policy/lib/before.js b/packages/generators/policy/lib/before.js deleted file mode 100644 index bac068d8fe..0000000000 --- a/packages/generators/policy/lib/before.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); -const { nameToSlug } = require('@strapi/utils'); - -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -/* eslint-disable prefer-template */ -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid( - 'Usage: `$ strapi generate:policy policyName --api apiName --plugin pluginName`' - ); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - let filePath; - if (scope.args.api) { - filePath = `./api/${scope.args.api}/config/policies`; - } else if (scope.args.plugin) { - filePath = `./plugins/${scope.args.plugin}/config/policies`; - } else { - filePath = './config/policies'; - } - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - name, - filePath, - filename: `${name}.js`, - }); - - // Trigger callback with no error to proceed. - return cb(); -}; diff --git a/packages/generators/policy/lib/index.js b/packages/generators/policy/lib/index.js deleted file mode 100644 index d2fb224abb..0000000000 --- a/packages/generators/policy/lib/index.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - ':filePath/:filename': { - template: 'policy.template', - }, - }, -}; diff --git a/packages/generators/service/.editorconfig b/packages/generators/service/.editorconfig deleted file mode 100644 index 473e45184b..0000000000 --- a/packages/generators/service/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[{package.json,*.yml}] -indent_style = space -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/generators/service/.gitignore b/packages/generators/service/.gitignore deleted file mode 100644 index 47e0ea73cc..0000000000 --- a/packages/generators/service/.gitignore +++ /dev/null @@ -1,104 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -package-lock.json - - - -############################ -# Tests -############################ - -testApp -coverage diff --git a/packages/generators/service/.npmignore b/packages/generators/service/.npmignore deleted file mode 100644 index 4ae4300882..0000000000 --- a/packages/generators/service/.npmignore +++ /dev/null @@ -1,109 +0,0 @@ -############################ -# OS X -############################ - -.DS_Store -.AppleDouble -.LSOverride -Icon -.Spotlight-V100 -.Trashes -._* - - -############################ -# Linux -############################ - -*~ - - -############################ -# Windows -############################ - -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.cab -*.msi -*.msm -*.msp - - -############################ -# Packages -############################ - -*.7z -*.csv -*.dat -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip -*.com -*.class -*.dll -*.exe -*.o -*.seed -*.so -*.swo -*.swp -*.swn -*.swm -*.out -*.pid - - -############################ -# Logs and databases -############################ - -*.log -*.sql -*.sqlite - - -############################ -# Misc. -############################ - -*# -ssl -.editorconfig -.idea -nbproject - - -############################ -# Node.js -############################ - -lib-cov -lcov.info -pids -logs -results -build -node_modules -.node_history -.snyk - - - -############################ -# Tests -############################ - -test -tests -__tests__ -jest.config.js -testApp -coverage diff --git a/packages/generators/service/.snyk b/packages/generators/service/.snyk deleted file mode 100644 index 7aca8c3f35..0000000000 --- a/packages/generators/service/.snyk +++ /dev/null @@ -1,9 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.12.0 -# ignores vulnerabilities until expiry date; change duration by modifying expiry date -ignore: - shelljs: - - '*': - reason: testing - expires: 2019-01-04T14:36:25.992Z -patch: {} diff --git a/packages/generators/service/LICENSE b/packages/generators/service/LICENSE deleted file mode 100644 index db018546b5..0000000000 --- a/packages/generators/service/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2015-present Strapi Solutions SAS - -Portions of the Strapi software are licensed as follows: - -* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". - -* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. - -MIT Expat License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/generators/service/README.md b/packages/generators/service/README.md deleted file mode 100644 index a6b1967faa..0000000000 --- a/packages/generators/service/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# strapi-generate-service - -[![npm version](https://img.shields.io/npm/v/strapi-generate-service.svg)](https://www.npmjs.org/package/strapi-generate-service) -[![npm downloads](https://img.shields.io/npm/dm/strapi-generate-service.svg)](https://www.npmjs.org/package/strapi-generate-service) -[![npm dependencies](https://david-dm.org/strapi/strapi-generate-service.svg)](https://david-dm.org/strapi/strapi-generate-service) -[![Build status](https://travis-ci.org/strapi/strapi-generate-service.svg?branch=master)](https://travis-ci.org/strapi/strapi-generate-service) -[![Slack status](https://slack.strapi.io/badge.svg)](https://slack.strapi.io) - -This Strapi generator contains the default files for a service. - -This generator can be called with: - -```bash -$ strapi generate:service serviceName apiName -``` - -For example if you want to generate a `sendEmail` service for the `email` API: - -```bash -$ strapi generate:service sendEmail email -``` - -## Resources - -- [License](LICENSE) - -## Links - -- [Strapi website](https://strapi.io/) -- [Strapi community on Slack](https://slack.strapi.io) -- [Strapi news on Twitter](https://twitter.com/strapijs) diff --git a/packages/generators/service/lib/before.js b/packages/generators/service/lib/before.js deleted file mode 100644 index a3ed04148e..0000000000 --- a/packages/generators/service/lib/before.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Public node modules. -const _ = require('lodash'); -const { nameToSlug } = require('@strapi/utils'); - -/** - * This `before` function is run before generating targets. - * Validate, configure defaults, get extra dependencies, etc. - * - * @param {Object} scope - * @param {Function} cb - */ - -/* eslint-disable prefer-template */ -module.exports = (scope, cb) => { - if (!scope.rootPath || !scope.id) { - return cb.invalid( - 'Usage: `$ strapi generate:service serviceName --api apiName --plugin pluginName`' - ); - } - - // Format `id`. - const name = scope.name || nameToSlug(scope.id); - - // `scope.args` are the raw command line arguments. - _.defaults(scope, { - name, - api: scope.args.api || scope.id, - }); - - // Determine the destination path. - let filePath; - if (scope.args.api) { - filePath = `./api/${scope.args.api}/services`; - } else if (scope.args.plugin) { - filePath = `./plugins/${scope.args.plugin}/services`; - } else { - filePath = `./api/${name}/services`; - } - - // Take another pass to take advantage of the defaults absorbed in previous passes. - _.defaults(scope, { - rootPath: scope.rootPath, - filePath, - filename: `${name}.js`, - }); - - // Trigger callback with no error to proceed. - return cb(); -}; diff --git a/packages/generators/service/lib/index.js b/packages/generators/service/lib/index.js deleted file mode 100644 index acc192c01e..0000000000 --- a/packages/generators/service/lib/index.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -/** - * Module dependencies - */ - -// Node.js core. -const path = require('path'); - -/** - * Generate a core API - */ - -module.exports = { - templatesDirectory: path.resolve(__dirname, '..', 'templates'), - before: require('./before'), - targets: { - ':filePath/:filename': { - template: 'service.template', - }, - }, -}; diff --git a/packages/generators/service/package.json b/packages/generators/service/package.json deleted file mode 100644 index e31078d4a6..0000000000 --- a/packages/generators/service/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@strapi/generate-service", - "version": "3.6.8", - "description": "Generate a service for a Strapi API.", - "homepage": "https://strapi.io", - "keywords": [ - "generate", - "generator", - "service", - "strapi" - ], - "main": "./lib/index.js", - "directories": { - "lib": "./lib" - }, - "dependencies": { - "lodash": "4.17.21", - "@strapi/utils": "3.6.8" - }, - "scripts": { - "test": "echo \"no tests yet\"" - }, - "author": { - "email": "hi@strapi.io", - "name": "Strapi team", - "url": "https://strapi.io" - }, - "maintainers": [ - { - "name": "Strapi team", - "email": "hi@strapi.io", - "url": "https://strapi.io" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/strapi/strapi.git" - }, - "bugs": { - "url": "https://github.com/strapi/strapi/issues" - }, - "engines": { - "node": ">=12.x.x <=16.x.x", - "npm": ">=6.0.0" - }, - "license": "SEE LICENSE IN LICENSE", - "gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53" -} diff --git a/packages/generators/service/templates/service.template b/packages/generators/service/templates/service.template deleted file mode 100644 index 2b4df98b29..0000000000 --- a/packages/generators/service/templates/service.template +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -/** - * `<%= name %>` service. - */ - -module.exports = { - // exampleService: (arg1, arg2) => { - // return isUserOnline(arg1, arg2); - // } -}; diff --git a/yarn.lock b/yarn.lock index b3391a21c6..4a8b1cc33b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2971,11 +2971,6 @@ estree-walker "^1.0.1" picomatch "^2.2.2" -"@sailshq/lodash@^3.10.2", "@sailshq/lodash@^3.10.3": - version "3.10.4" - resolved "https://registry.yarnpkg.com/@sailshq/lodash/-/lodash-3.10.4.tgz#2299648a81a67f4c6ee222c6cf8e261bd9c3fa50" - integrity sha512-YXJqp9gdHcZKAmBY/WnwFpPtNQp2huD/ME2YMurH2YHJvxrVzYsmpKw/pb7yINArRpp8E++fwbQd3ajYXGA45Q== - "@sendgrid/client@^6.4.0": version "6.5.5" resolved "https://registry.yarnpkg.com/@sendgrid/client/-/client-6.5.5.tgz#66cf569445d98a795998a894bb432a9939ead7c3" @@ -6231,16 +6226,6 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001245.tgz#45b941bbd833cb0fa53861ff2bae746b3c6ca5d4" integrity sha512-768fM9j1PKXpOCKws6eTo3RHmvTUsG9UrpT4WoREFeZgJBTi4/X9g565azS/rVUGtqb8nt7FjLeF5u4kukERnA== -captains-log@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/captains-log/-/captains-log-2.0.3.tgz#4fa10b4f389a62299872826fc6736704e7483469" - integrity sha512-hKlNLw/4Qz1vPDhAbn3pRexi8fzY7d3SwX/BtI2lMG09UqK1W1mf2pYFslau3ZPWxdcwBBcsLLi9ngs+xhqD2Q== - dependencies: - "@sailshq/lodash" "^3.10.2" - chalk "1.1.3" - rc "1.2.8" - semver "5.4.1" - capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -6253,7 +6238,15 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -chalk@1.1.3, chalk@^1.1.3: +chalk@4.1.1, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" + integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= @@ -6264,14 +6257,6 @@ chalk@1.1.3, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@4.1.1, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" - integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -14779,7 +14764,7 @@ node-notifier@^8.0.0: uuid "^8.3.0" which "^2.0.2" -node-plop@~0.26.2: +node-plop@0.26.2, node-plop@~0.26.2: version "0.26.2" resolved "https://registry.yarnpkg.com/node-plop/-/node-plop-0.26.2.tgz#c2523596dab4e28360e615b768b11b4d60d5b1b9" integrity sha512-q444beWkMvZwAiYC3BRGJUHgRlpOItQHy+xdy6egXg8KjxDY/Ro309spQTNvH01qK9A8XF6pc0xLKbrHDpxW7w== @@ -17088,7 +17073,7 @@ rc-util@^4.5.1: react-lifecycles-compat "^3.0.4" shallowequal "^1.1.0" -rc@1.2.8, rc@^1.2.7, rc@^1.2.8: +rc@^1.2.7, rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -17878,14 +17863,6 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -reportback@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/reportback/-/reportback-2.0.2.tgz#8957ff5f6b1675e0284c1a14001a24463c0f9900" - integrity sha512-EOF6vRKfXjI7ydRoOdXXeRTK1zgWq7mep8/32patt0FOnBap32eTSw6yCea/o0025PHmVB8crx5OxzZJ+/P34g== - dependencies: - captains-log "^2.0.2" - switchback "^2.0.1" - request-compose@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/request-compose/-/request-compose-2.1.4.tgz#d427d614d31c0300e5893cbeaf86e51da1dff445" @@ -18433,11 +18410,6 @@ semver-diff@^3.1.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" - integrity sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg== - semver@7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" @@ -20099,13 +20071,6 @@ swap-case@^1.1.0: lower-case "^1.1.1" upper-case "^1.1.1" -switchback@^2.0.1: - version "2.0.5" - resolved "https://registry.yarnpkg.com/switchback/-/switchback-2.0.5.tgz#2f50c91118f659c42e03c0f2bdb094f868c45336" - integrity sha512-w9gnsTxR5geOKt45QUryhDP9KTLcOAqje9usR2VQ2ng8DfhaF+mkIcArxioMP/p6Z/ecKE58i2/B0DDlMJK1jw== - dependencies: - "@sailshq/lodash" "^3.10.3" - symbol-observable@^1.0.4: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"