create-strapi-app 0.0.0-4fc90398602f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +35 -0
- package/create-strapi-app.js +99 -0
- package/index.js +5 -0
- package/package.json +50 -0
- package/utils/prompt-user.js +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015-present Strapi Solutions SAS
|
|
2
|
+
|
|
3
|
+
Portions of the Strapi software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
|
|
6
|
+
|
|
7
|
+
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
|
+
|
|
9
|
+
MIT Expat License
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
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
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Create strapi app
|
|
2
|
+
|
|
3
|
+
This package includes the `create-strapi-app` CLI to make the creation of a strapi project lighter.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
### Quick usage (recommended)
|
|
8
|
+
|
|
9
|
+
Using yarn create command
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
yarn create strapi-app my-project
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Using npx
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
npx create-strapi-app my-project
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Manual install
|
|
22
|
+
|
|
23
|
+
Using yarn
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
yarn global add create-strapi-app
|
|
27
|
+
create-strapi-app my-app
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Using npm
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npm install -g create-strapi-app
|
|
34
|
+
create-strapi-app my-app
|
|
35
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { resolve } = require('path');
|
|
4
|
+
const commander = require('commander');
|
|
5
|
+
const { checkInstallPath, generateNewApp } = require('@strapi/generate-new');
|
|
6
|
+
const promptUser = require('./utils/prompt-user');
|
|
7
|
+
// eslint-disable-next-line import/extensions
|
|
8
|
+
const packageJson = require('./package.json');
|
|
9
|
+
|
|
10
|
+
const program = new commander.Command(packageJson.name);
|
|
11
|
+
|
|
12
|
+
const databaseOptions = [
|
|
13
|
+
'dbclient',
|
|
14
|
+
'dbhost',
|
|
15
|
+
'dbport',
|
|
16
|
+
'dbname',
|
|
17
|
+
'dbusername',
|
|
18
|
+
'dbpassword',
|
|
19
|
+
'dbssl',
|
|
20
|
+
'dbfile',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.version(packageJson.version)
|
|
25
|
+
.arguments('[directory]')
|
|
26
|
+
.option('--no-run', 'Do not start the application after it is created')
|
|
27
|
+
.option('--use-npm', 'Force usage of npm instead of yarn to create the project')
|
|
28
|
+
.option('--debug', 'Display database connection error')
|
|
29
|
+
.option('--quickstart', 'Quickstart app creation')
|
|
30
|
+
.option('--dbclient <dbclient>', 'Database client')
|
|
31
|
+
.option('--dbhost <dbhost>', 'Database host')
|
|
32
|
+
.option('--dbport <dbport>', 'Database port')
|
|
33
|
+
.option('--dbname <dbname>', 'Database name')
|
|
34
|
+
.option('--dbusername <dbusername>', 'Database username')
|
|
35
|
+
.option('--dbpassword <dbpassword>', 'Database password')
|
|
36
|
+
.option('--dbssl <dbssl>', 'Database SSL')
|
|
37
|
+
.option('--dbfile <dbfile>', 'Database file path for sqlite')
|
|
38
|
+
.option('--dbforce', 'Overwrite database content if any')
|
|
39
|
+
.option('--template <templateurl>', 'Specify a Strapi template')
|
|
40
|
+
.option('--ts, --typescript', 'Use TypeScript to generate the project')
|
|
41
|
+
.description('create a new application')
|
|
42
|
+
.action((directory) => {
|
|
43
|
+
initProject(directory, program);
|
|
44
|
+
})
|
|
45
|
+
.parse(process.argv);
|
|
46
|
+
|
|
47
|
+
function generateApp(projectName, options) {
|
|
48
|
+
if (!projectName) {
|
|
49
|
+
console.error('Please specify the <directory> of your project when using --quickstart');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return generateNewApp(projectName, options).then(() => {
|
|
54
|
+
if (process.platform === 'win32') {
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function initProject(projectName, program) {
|
|
61
|
+
if (projectName) {
|
|
62
|
+
await checkInstallPath(resolve(projectName));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const hasDatabaseOptions = databaseOptions.some((opt) => program[opt]);
|
|
66
|
+
|
|
67
|
+
if (program.quickstart && hasDatabaseOptions) {
|
|
68
|
+
console.error(
|
|
69
|
+
`The quickstart option is incompatible with the following options: ${databaseOptions.join(
|
|
70
|
+
', '
|
|
71
|
+
)}`
|
|
72
|
+
);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (hasDatabaseOptions) {
|
|
77
|
+
program.quickstart = false; // Will disable the quickstart question because != 'undefined'
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (program.quickstart) {
|
|
81
|
+
return generateApp(projectName, program);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const prompt = await promptUser(projectName, program, hasDatabaseOptions);
|
|
85
|
+
const directory = prompt.directory || projectName;
|
|
86
|
+
await checkInstallPath(resolve(directory));
|
|
87
|
+
|
|
88
|
+
const options = {
|
|
89
|
+
template: program.template,
|
|
90
|
+
quickstart: prompt.quick || program.quickstart,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const generateStrapiAppOptions = {
|
|
94
|
+
...program,
|
|
95
|
+
...options,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return generateApp(directory, generateStrapiAppOptions);
|
|
99
|
+
}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-strapi-app",
|
|
3
|
+
"version": "0.0.0-4fc90398602f",
|
|
4
|
+
"description": "Generate a new Strapi application.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"create-strapi-app",
|
|
7
|
+
"create",
|
|
8
|
+
"new",
|
|
9
|
+
"generate",
|
|
10
|
+
"strapi"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://strapi.io",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Strapi Solutions SAS",
|
|
23
|
+
"email": "hi@strapi.io",
|
|
24
|
+
"url": "https://strapi.io"
|
|
25
|
+
},
|
|
26
|
+
"maintainers": [
|
|
27
|
+
{
|
|
28
|
+
"name": "Strapi Solutions SAS",
|
|
29
|
+
"email": "hi@strapi.io",
|
|
30
|
+
"url": "https://strapi.io"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"main": "./index.js",
|
|
34
|
+
"bin": {
|
|
35
|
+
"create-strapi-app": "./index.js"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "echo \"no tests yet\""
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@strapi/generate-new": "0.0.0-4fc90398602f",
|
|
42
|
+
"commander": "6.1.0",
|
|
43
|
+
"inquirer": "8.2.4"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=14.19.1 <=16.x.x",
|
|
47
|
+
"npm": ">=6.0.0"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "4fc90398602f4a07f8ae8f04968c48d669992707"
|
|
50
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const inquirer = require('inquirer');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string|null} projectName - The name/path of project
|
|
7
|
+
* @param {string|null} template - The Github repo of the template
|
|
8
|
+
* @returns Object containting prompt answers
|
|
9
|
+
*/
|
|
10
|
+
module.exports = async function promptUser(projectName, program, hasDatabaseOptions) {
|
|
11
|
+
const questions = await getPromptQuestions(projectName, program, hasDatabaseOptions);
|
|
12
|
+
return inquirer.prompt(questions);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string|null} projectName - The name of the project
|
|
17
|
+
* @param {string|null} template - The template the project should use
|
|
18
|
+
* @returns Array of prompt question objects
|
|
19
|
+
*/
|
|
20
|
+
async function getPromptQuestions(projectName, program, hasDatabaseOptions) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: 'input',
|
|
24
|
+
default: 'my-strapi-project',
|
|
25
|
+
name: 'directory',
|
|
26
|
+
message: 'What would you like to name your project?',
|
|
27
|
+
when: !projectName,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'list',
|
|
31
|
+
name: 'quick',
|
|
32
|
+
message: 'Choose your installation type',
|
|
33
|
+
when: !program.quickstart && !hasDatabaseOptions,
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
name: 'Quickstart (recommended)',
|
|
37
|
+
value: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Custom (manual settings)',
|
|
41
|
+
value: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|