create-sy 2.1.20-alpha.0 → 2.1.31-alpha.0
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/README.md +19 -10
- package/build/constants.js +2 -0
- package/build/createSyngrisiProject.js +1 -1
- package/build/index.js +9 -6
- package/build/utils.js +18 -6
- package/package.json +5 -5
- package/typedoc.config.cjs +6 -0
package/README.md
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
# Syngrisi
|
|
1
|
+
# Syngrisi Project Initializer
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This command line tool is for creating and installing a new Syngrisi project with required configurations and
|
|
4
|
+
dependencies, allowing you to get started quickly.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
This initializer is for installing Syngrisi in native mode, therefore you need `Node.js >= v14.20.0`and `MongoDB >= 7.0` or remote MongoDB instance. If you want to install a dockerized Syngrisi service, please read the [Syngrisi documentation](https://github.com/syngrisi/syngrisi/tree/main/packages/syngrisi#readme).
|
|
4
9
|
|
|
5
10
|
## Usage
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
To install a new Syngrisi project in the current directory, run:
|
|
8
13
|
|
|
9
14
|
```bash
|
|
10
15
|
npm init sy@latest
|
|
11
16
|
```
|
|
12
17
|
|
|
13
18
|
## CLI options
|
|
14
|
-
The command accepts the following options:
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
The installation command supports the following options:
|
|
21
|
+
|
|
22
|
+
`DIRECTORY` - The directory where your Syngrisi project will be installed. The default is the current working directory if this option is omitted.
|
|
17
23
|
|
|
18
|
-
`-f, --force` -
|
|
24
|
+
`-f, --force` - Ignore pre-install checks (Docker, MongoDB, Node.js versions) and force the installation.
|
|
19
25
|
|
|
20
26
|
`-y, --yes` - Automatically confirm the installation.
|
|
21
27
|
|
|
22
|
-
`--npmTag` -
|
|
28
|
+
`--npmTag` - Determine the Syngrisi package version to install. Defaults to the latest version when not specified.
|
|
23
29
|
|
|
24
|
-
`--help` -
|
|
25
|
-
|
|
30
|
+
`--help` - Display help information and exit.
|
|
31
|
+
|
|
32
|
+
Example:
|
|
26
33
|
|
|
27
34
|
```bash
|
|
28
35
|
npm init sy my-app-dir -- -f -y
|
|
29
36
|
```
|
|
30
37
|
|
|
31
|
-
This command
|
|
38
|
+
This command initializes a Syngrisi project in my-app-dir, bypassing pre-install checks and confirming prompts
|
|
39
|
+
automatically.
|
|
40
|
+
|
|
32
41
|
|
|
33
42
|
|
package/build/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export const MONGODB_SETUP_MANUAL_URL = 'https://www.mongodb.com/docs/manual/installation/';
|
|
2
2
|
export const DOCKER_SETUP_MANUAL_URL = 'https://docs.docker.com/engine/install/';
|
|
3
|
+
export const SYNGRISI_DOCUMENTATION_LINK = 'https://github.com/syngrisi/syngrisi/tree/main/packages/syngrisi#readme';
|
|
3
4
|
export const NODE_VERSION = '>=14';
|
|
5
|
+
export const MONGODB_VERSION = '>=7.0';
|
|
@@ -33,5 +33,5 @@ export const createSyngrisiProject = async (opts) => {
|
|
|
33
33
|
spinner.stop();
|
|
34
34
|
console.log(chalk.green(`✔ Syngrisi ${chalk.greenBright(getSyngrisiVersion(root))} successfully installed in the following directory: ${root}`));
|
|
35
35
|
console.log(chalk.white(`To run the application use the ${chalk.whiteBright('npx sy')} command`));
|
|
36
|
-
console.log(chalk.white.bold('For detailed configuration see https://github.com/
|
|
36
|
+
console.log(chalk.white.bold('For detailed configuration see https://github.com/syngrisi/syngrisi/tree/main/packages/syngrisi'));
|
|
37
37
|
};
|
package/build/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// noinspection ExceptionCaughtLocallyJS
|
|
2
2
|
import * as utils from './utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { MONGODB_SETUP_MANUAL_URL, MONGODB_VERSION, NODE_VERSION, SYNGRISI_DOCUMENTATION_LINK } from './constants.js';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { createSyngrisiProject } from './createSyngrisiProject.js';
|
|
6
|
+
import { checkMongoDB } from './utils.js';
|
|
6
7
|
export async function run() {
|
|
7
8
|
try {
|
|
8
9
|
const args = utils.parseArguments();
|
|
@@ -28,14 +29,16 @@ export async function run() {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
if (args.force === undefined && !args._.includes('--force')) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
+ `Please install Docker Compose if you want to run Syngrisi inside containers. ${DOCKER_SETUP_MANUAL_URL}\n`));
|
|
34
|
-
}
|
|
35
|
-
if (!utils.checkMongoDB()) {
|
|
32
|
+
const mongoCheck = checkMongoDB();
|
|
33
|
+
if (!mongoCheck || (!mongoCheck.supported && (mongoCheck.version === 'unknown'))) {
|
|
36
34
|
console.log(chalk.yellow('⚠️ MongoDB is not installed.'
|
|
37
35
|
+ `Please install MongoDB if you want to run Syngrisi in the native mode. ${MONGODB_SETUP_MANUAL_URL}\n`));
|
|
38
36
|
}
|
|
37
|
+
if (!mongoCheck.supported && (mongoCheck.version !== 'unknown')) {
|
|
38
|
+
console.log(chalk.yellow(`⚠️ Wrong MongoDB version: '${mongoCheck.version}' `
|
|
39
|
+
+ `Please install the proper MongoDB version: '${MONGODB_VERSION}' if you want to run Syngrisi in the native mode. ${MONGODB_SETUP_MANUAL_URL}\n`
|
|
40
|
+
+ `Or use standalone remote MongoDB instance, for more information read Syngrisi documentation ${SYNGRISI_DOCUMENTATION_LINK}.`));
|
|
41
|
+
}
|
|
39
42
|
const versionObj = utils.checkNodeVersion();
|
|
40
43
|
if (!versionObj.supported) {
|
|
41
44
|
const msg = `❌ This version: '${versionObj.version}' of Node.js is not supported. Please use Node.js version ${NODE_VERSION}\n`;
|
package/build/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import child_process from 'node:child_process';
|
|
3
3
|
import fss from 'node:fs';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
|
-
import { NODE_VERSION } from './constants.js';
|
|
5
|
+
import { MONGODB_VERSION, NODE_VERSION } from './constants.js';
|
|
6
6
|
import semver from 'semver';
|
|
7
7
|
import minimist from 'minimist';
|
|
8
8
|
import path from 'node:path';
|
|
@@ -46,15 +46,27 @@ export const prompt = async (message) => {
|
|
|
46
46
|
]);
|
|
47
47
|
return answer;
|
|
48
48
|
};
|
|
49
|
+
export const getInstalledMongoVersion = () => {
|
|
50
|
+
const versionOutput = child_process.execSync('mongod1 --version').toString();
|
|
51
|
+
const versionMatch = versionOutput.match(/db version v(\d+\.\d+\.\d+)/);
|
|
52
|
+
if (!versionMatch) {
|
|
53
|
+
throw new Error(chalk.red(`❌ Cannot parse MongoDB version, output: '${versionOutput}'`));
|
|
54
|
+
}
|
|
55
|
+
return versionMatch[1];
|
|
56
|
+
};
|
|
49
57
|
export const checkMongoDB = () => {
|
|
50
58
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
const installedVersion = getInstalledMongoVersion();
|
|
60
|
+
if (!semver.satisfies(installedVersion, MONGODB_VERSION)) {
|
|
61
|
+
console.error(chalk.red(`❌ MongoDB version is not satisfies requirements: '${MONGODB_VERSION}'. Installed version is '${installedVersion}'.`));
|
|
62
|
+
return { version: installedVersion, supported: false };
|
|
63
|
+
}
|
|
64
|
+
console.log(chalk.green(`✔ MongoDB version is satisfactory. Installed version is ${installedVersion}.`));
|
|
65
|
+
return { version: installedVersion, supported: true };
|
|
54
66
|
}
|
|
55
67
|
catch (error) {
|
|
56
|
-
console.error(chalk.yellow(error.message));
|
|
57
|
-
return false;
|
|
68
|
+
console.error(chalk.yellow(`Error checking MongoDB version: ${error.message}`));
|
|
69
|
+
return { version: 'unknown', supported: false };
|
|
58
70
|
}
|
|
59
71
|
};
|
|
60
72
|
export function printAndExit(error, signal) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sy",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.31-alpha.0",
|
|
4
4
|
"description": "Install and setup Syngrisi",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Viktar Silakou",
|
|
7
7
|
"email": "1105714@gmail.com"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"homepage": "https://github.com/
|
|
10
|
+
"homepage": "https://github.com/syngrisi/syngrisi/tree/main/packages/create-sy",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+
|
|
13
|
+
"url": "git+git@github.com:syngrisi/syngrisi.git",
|
|
14
14
|
"directory": "packages/create-sy"
|
|
15
15
|
},
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/syngrisi/syngrisi/issues"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"Syngrisi",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"read-pkg-up": "^10.1.0",
|
|
73
73
|
"semver": "^7.3.8"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "adc129857801f07ff80a435887ddd04fe4182962"
|
|
76
76
|
}
|