mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Org package to be consistent, complete package.json and add missing package files
This commit is contained in:
parent
526a2ce671
commit
89b02e871e
@ -5,7 +5,7 @@
|
||||
testApp/**
|
||||
examples/**
|
||||
cypress/**
|
||||
packages/generators/generate/files/
|
||||
packages/generators/generators/lib/files/
|
||||
packages/core/helper-plugin/build/**
|
||||
packages/core/helper-plugin/lib/src/components/**
|
||||
packages/core/helper-plugin/lib/src/testUtils/**
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"@strapi/generate": "3.6.8",
|
||||
"@strapi/generators": "3.6.8",
|
||||
"@strapi/helper-plugin": "3.6.8",
|
||||
"@strapi/utils": "3.6.8",
|
||||
"fs-extra": "^9.1.0",
|
||||
|
||||
@ -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,7 +127,7 @@ const createContentType = async ({ contentType, components = [] }, options = {})
|
||||
* @param {string} name
|
||||
*/
|
||||
const generateAPI = ({ name, kind = 'collectionType' }) => {
|
||||
return generator.generate('api', { id: nameToSlug(name), kind }, { dir: strapi.dir });
|
||||
return strapiGenerators.generate('api', { id: nameToSlug(name), kind }, { dir: strapi.dir });
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -124,7 +124,8 @@ program
|
||||
.description('Launch interactive API generator')
|
||||
.action(() => {
|
||||
checkCwdIsStrapiApp('generate');
|
||||
require('@strapi/generate').execute();
|
||||
process.argv.splice(2, 1);
|
||||
require('@strapi/generators').runCLI();
|
||||
});
|
||||
|
||||
// `$ strapi generate:template <directory>`
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
"@koa/cors": "^3.0.0",
|
||||
"@strapi/admin": "3.6.8",
|
||||
"@strapi/database": "3.6.8",
|
||||
"@strapi/generate": "3.6.8",
|
||||
"@strapi/generators": "3.6.8",
|
||||
"@strapi/generate-new": "3.6.8",
|
||||
"@strapi/logger": "3.6.8",
|
||||
"@strapi/utils": "3.6.8",
|
||||
@ -135,4 +135,4 @@
|
||||
"reactjs"
|
||||
],
|
||||
"gitHead": "231263a3535658bab1e9492c6aaaed8692d62a53"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "@strapi/generate",
|
||||
"version": "3.6.8",
|
||||
"description": "Interactive API generator.",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
103
packages/generators/generators/.npmignore
Normal file
103
packages/generators/generators/.npmignore
Normal file
@ -0,0 +1,103 @@
|
||||
############################
|
||||
# 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
|
||||
|
||||
|
||||
############################
|
||||
# Misc.
|
||||
############################
|
||||
|
||||
*#
|
||||
ssl
|
||||
.editorconfig
|
||||
.gitattributes
|
||||
.idea
|
||||
nbproject
|
||||
|
||||
|
||||
############################
|
||||
# Node.js
|
||||
############################
|
||||
|
||||
lib-cov
|
||||
lcov.info
|
||||
pids
|
||||
logs
|
||||
results
|
||||
node_modules
|
||||
.node_history
|
||||
|
||||
|
||||
############################
|
||||
# Tests
|
||||
############################
|
||||
|
||||
test
|
||||
testApp
|
||||
coverage
|
||||
22
packages/generators/generators/LICENSE
Normal file
22
packages/generators/generators/LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
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.
|
||||
18
packages/generators/generators/README.md
Normal file
18
packages/generators/generators/README.md
Normal file
@ -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
|
||||
@ -1,21 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
process.argv.splice(2, 1);
|
||||
|
||||
const { join } = require('path');
|
||||
const { Plop, run } = require('plop');
|
||||
const nodePlop = require('node-plop');
|
||||
|
||||
const execute = () => {
|
||||
/**
|
||||
* Starts the Plop CLI programmatically
|
||||
*/
|
||||
const runCLI = () => {
|
||||
Plop.launch({ configPath: join(__dirname, 'plopfile.js') }, env =>
|
||||
run({ ...env, dest: process.cwd() }, undefined, true)
|
||||
);
|
||||
};
|
||||
|
||||
const generate = async (action, options, { dir = process.cwd() } = {}) => {
|
||||
/**
|
||||
* 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(action);
|
||||
const generator = plop.getGenerator(generatorName);
|
||||
await generator.runActions(options, {
|
||||
onSuccess: () => {},
|
||||
onFailure: () => {},
|
||||
@ -25,5 +33,5 @@ const generate = async (action, options, { dir = process.cwd() } = {}) => {
|
||||
|
||||
module.exports = {
|
||||
generate,
|
||||
execute,
|
||||
runCLI,
|
||||
};
|
||||
@ -33,10 +33,8 @@ module.exports = plop => {
|
||||
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()
|
||||
);
|
||||
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');
|
||||
@ -4,7 +4,7 @@ const getDestinationPrompts = require('./utils/get-destination-prompts');
|
||||
const getFilePath = require('./utils/get-file-path');
|
||||
const validateInput = require('./utils/validate-input');
|
||||
|
||||
module.exports = (plop) => {
|
||||
module.exports = plop => {
|
||||
// Controller generator
|
||||
plop.setGenerator('controller', {
|
||||
description: 'Generate a controller for an API',
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
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
|
||||
@ -32,6 +33,7 @@ const promptConfigQuestions = (plop, inquirer) => {
|
||||
type: 'input',
|
||||
name: 'id',
|
||||
message: 'Model name',
|
||||
validate: input => validateInput(input),
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
@ -41,6 +43,7 @@ const promptConfigQuestions = (plop, inquirer) => {
|
||||
{ name: 'Collection Type', value: 'collectionType' },
|
||||
{ name: 'Singe Type', value: 'singleType' },
|
||||
],
|
||||
validate: input => validateInput(input),
|
||||
},
|
||||
...getDestinationPrompts('model', plop.getDestBasePath()),
|
||||
{
|
||||
@ -62,6 +65,7 @@ const promptAttributeQuestions = inquirer => {
|
||||
type: 'input',
|
||||
name: 'attributeName',
|
||||
message: 'Name of attribute',
|
||||
validate: input => validateInput(input),
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
@ -1,9 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { join } = require('path');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = (plop) => {
|
||||
module.exports = plop => {
|
||||
// Plugin generator
|
||||
plop.setGenerator('plugin', {
|
||||
description: 'Generate a basic plugin',
|
||||
@ -14,9 +11,14 @@ module.exports = (plop) => {
|
||||
message: 'Plugin name',
|
||||
},
|
||||
],
|
||||
actions: answers => {
|
||||
fs.copySync(join(__dirname, '..', 'files', 'plugin'), join('plugins', answers.id));
|
||||
actions: () => {
|
||||
return [
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: 'plugins/{{id}}/admin',
|
||||
base: 'files/plugin/admin',
|
||||
templateFiles: 'files/plugin/admin/**',
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'plugins/{{id}}/services/{{id}}.js',
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
const getDestinationPrompts = require('./utils/get-destination-prompts');
|
||||
|
||||
module.exports = (plop) => {
|
||||
module.exports = plop => {
|
||||
// Policy generator
|
||||
plop.setGenerator('policy', {
|
||||
description: 'Generate a policy for an API',
|
||||
@ -21,7 +21,7 @@ module.exports = (plop) => {
|
||||
} else if (answers.destination === 'plugin') {
|
||||
filePath = `plugins/{{plugin}}`;
|
||||
} else {
|
||||
filePath = ``;
|
||||
filePath = `./`;
|
||||
}
|
||||
|
||||
return [
|
||||
@ -3,7 +3,7 @@
|
||||
const getDestinationPrompts = require('./utils/get-destination-prompts');
|
||||
const getFilePath = require('./utils/get-file-path');
|
||||
|
||||
module.exports = (plop) => {
|
||||
module.exports = plop => {
|
||||
// Service generator
|
||||
plop.setGenerator('service', {
|
||||
description: 'Generate a service for an API',
|
||||
@ -30,8 +30,9 @@ module.exports = (action, basePath) => {
|
||||
throw Error('Couldn\'t find an "api" directory');
|
||||
}
|
||||
|
||||
const apiDir = await fs.readdir(apiPath);
|
||||
const apiDirContent = apiDir.filter(api => fs.lstatSync(join(apiPath, api)).isDirectory());
|
||||
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');
|
||||
}
|
||||
@ -45,7 +46,7 @@ module.exports = (action, basePath) => {
|
||||
message: 'Which plugin is this for?',
|
||||
name: 'plugin',
|
||||
choices: async () => {
|
||||
const pluginsPath = join(basePath, 'plugins');
|
||||
const pluginsPath = join(basePath, 'plugins');
|
||||
const exists = await fs.pathExists(pluginsPath);
|
||||
|
||||
if (!exists) {
|
||||
41
packages/generators/generators/package.json
Normal file
41
packages/generators/generators/package.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "@strapi/generators",
|
||||
"version": "3.6.8",
|
||||
"description": "Interactive API generator.",
|
||||
"keywords": [
|
||||
"strapi",
|
||||
"generators"
|
||||
],
|
||||
"homepage": "https://strapi.io",
|
||||
"bugs": {
|
||||
"url": "https://github.com/strapi/strapi/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/strapi/strapi.git"
|
||||
},
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"author": {
|
||||
"name": "Strapi team",
|
||||
"email": "hi@strapi.io",
|
||||
"url": "https://strapi.io"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Strapi team",
|
||||
"email": "hi@strapi.io",
|
||||
"url": "https://strapi.io"
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user