@aexol/axolotl 0.0.1

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/.eslintrc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "../../.eslintrc.json"
4
+ ]
5
+ }
@@ -0,0 +1,40 @@
1
+ export const MESSAGE_BRAKE = `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`;
2
+ export const BASE_REPOSITORY = `git@github.com:aexol-studio/axolotl.git`;
3
+
4
+ type T = {
5
+ [key in STARTERS]: {
6
+ example: string;
7
+ repo: `axolotl-starter-${key}`;
8
+ description: string;
9
+ };
10
+ };
11
+
12
+ export type STARTERS = 'stucco' | 'yoga';
13
+
14
+ /**
15
+ * ```
16
+ * example: 'beerpub',
17
+ * ```
18
+ * folder name placed at examples folder
19
+ * ```
20
+ * repo: 'axolotl-starter-stucco',
21
+ * ```
22
+ * repository name
23
+ * ```
24
+ * description: 'stucco.js starter',
25
+ * ```
26
+ * description of starter
27
+ * ```
28
+ */
29
+ export const STARTER_DICT: T = {
30
+ stucco: {
31
+ example: 'beerpub',
32
+ repo: 'axolotl-starter-stucco',
33
+ description: 'stucco.js starter',
34
+ },
35
+ yoga: {
36
+ example: 'beerpub-yoga',
37
+ repo: 'axolotl-starter-yoga',
38
+ description: 'GraphQL Yoga starter',
39
+ },
40
+ };
@@ -0,0 +1,32 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+
4
+ import { STARTER_DICT, STARTERS } from './consts.js';
5
+ import { createAppAction } from './utils.js';
6
+
7
+ export const createApp = (program: Command) => {
8
+ Object.entries(STARTER_DICT).forEach(([key, { description: _description, repo, example }]) => {
9
+ const starter = key as STARTERS;
10
+ const command = `create-${starter} [dir]`;
11
+ const description = `${chalk.magenta('Axolotl Starter')} - ${_description}`;
12
+ program
13
+ .command(command)
14
+ .description(description)
15
+ .action((destination) => createAppAction({ starter, repo, example, destination }))
16
+ .on('--help', () => {
17
+ console.log('');
18
+ console.log(
19
+ ` ${chalk.magenta(
20
+ '[dir?: string]',
21
+ )} - optional argument, if not provided, starter will be created in ${chalk.red('generated')} directory`,
22
+ );
23
+ console.log('');
24
+ console.log(chalk.gray(`New project in ${chalk.red('generated')} directory`));
25
+ console.log(`$ axolotl create-${starter}`);
26
+ console.log('');
27
+ console.log(chalk.gray(`New project in ${chalk.magenta('passed')} destination`));
28
+ console.log(`$ axolotl create-${starter} test/my-graphql-server`);
29
+ console.log('');
30
+ });
31
+ });
32
+ };
@@ -0,0 +1,173 @@
1
+ import fs from 'fs';
2
+ import * as path from 'path';
3
+ import { execSync } from 'child_process';
4
+ import chalk, { Color } from 'chalk';
5
+
6
+ import { BASE_REPOSITORY, MESSAGE_BRAKE } from './consts.js';
7
+
8
+ type Message = { message: string; color?: typeof Color };
9
+
10
+ export const createAppAction = ({
11
+ starter,
12
+ repo,
13
+ example,
14
+ destination: _destination,
15
+ }: {
16
+ starter: string;
17
+ repo: string;
18
+ example: string;
19
+ destination?: string;
20
+ }) => {
21
+ const destination = _destination ? _destination : './';
22
+ const name = _destination ? '.' : repo;
23
+ const path = correctPath(destination, name);
24
+
25
+ const installationMessages = [
26
+ {
27
+ message: `Installing starter ${chalk.magenta('GraphQL Axolotl Server')} - GraphQL ${firstLetterToUpperCase(
28
+ starter,
29
+ )} example...`,
30
+ },
31
+ { message: `This may take a while...`, color: 'white' as const },
32
+ ];
33
+ log(installationMessages);
34
+
35
+ const trigger = runCommands(path, example);
36
+ if ('success' in trigger) {
37
+ const successMessages = [
38
+ {
39
+ message: `Starter ${chalk.magenta('GraphQL Axolotl Server')} - GraphQL ${firstLetterToUpperCase(
40
+ starter,
41
+ )} example created.`,
42
+ },
43
+ { message: `To run it, type:`, color: 'white' as const },
44
+ {
45
+ message: `cd ${chalk.magenta(`${path}`)} && ${chalk.magenta(`npm run start`)}`,
46
+ color: 'yellow' as const,
47
+ },
48
+ ];
49
+
50
+ log(successMessages);
51
+ } else {
52
+ const errorMessages = [
53
+ { message: `Starter ${chalk.magenta('GraphQL Axolotl Server')} failed.`, color: 'red' as const },
54
+ { message: ``, color: 'white' as const },
55
+ { message: `${chalk.yellow('Reason:')} ${trigger.error}`, color: 'white' as const },
56
+ ];
57
+
58
+ log(errorMessages, true);
59
+ process.exit(1);
60
+ }
61
+ };
62
+
63
+ function runCommands(path: string, example: string): { error: string } | { success: boolean } {
64
+ try {
65
+ const system = checkSystem({ node: '16.20' });
66
+ if (system.error) return { error: system.error };
67
+
68
+ if (fs.existsSync(path)) return { error: 'folder already exists' };
69
+ if (!isPathValid(path)) return { error: 'invalid path' };
70
+ if (!runCommand(`git --version`, false)) return { error: 'git is not installed' };
71
+
72
+ const clone = runCommand(`git clone -n --depth=1 --filter=tree:0 ${BASE_REPOSITORY} ${path}`);
73
+ if (!clone) return { error: "can't clone repository" };
74
+
75
+ const checkout = runCommand(
76
+ `cd ${path} && git config core.sparseCheckout true && git sparse-checkout set examples/${example} && git checkout && git config core.sparseCheckout false`,
77
+ );
78
+ if (!checkout) return { error: "can't clone repository" };
79
+
80
+ let copy;
81
+ if (system.platform === 'win32') {
82
+ copy = runCommand(`cd ${path} && xcopy /E /Y examples\\${example} . && rmdir /S /Q examples`);
83
+ } else copy = runCommand(`cd ${path} && cp -r examples/${example}/* . && rm -rf examples`);
84
+ if (!copy) return { error: "can't clone repository" };
85
+
86
+ let cleanUpGit;
87
+ if (system.platform === 'win32') {
88
+ cleanUpGit = runCommand(`cd ${path} && rmdir /S /Q .git`);
89
+ } else cleanUpGit = runCommand(`cd ${path} && rm -rf .git`);
90
+ if (!cleanUpGit) return { error: "can't clone repository" };
91
+
92
+ // init new git - if fails nothing happens we can continue
93
+ runCommand(`cd ${path} && git init --quiet`, false);
94
+ if (!runCommand(`cd ${path} && npm install`)) return { error: 'problem with installing dependencies' };
95
+
96
+ return { success: true };
97
+ } catch (error) {
98
+ return { error: 'command failed' };
99
+ }
100
+ }
101
+
102
+ const runCommand = (command: string, withLog = true) => {
103
+ try {
104
+ const stdio = withLog ? 'inherit' : 'ignore';
105
+ execSync(command, { stdio });
106
+ } catch (e) {
107
+ if (withLog) log([{ message: `Command ${command} failed.`, color: 'red' as const }]);
108
+ return false;
109
+ }
110
+ return true;
111
+ };
112
+
113
+ const firstLetterToUpperCase = (str: string) => {
114
+ return str.charAt(0).toUpperCase() + str.slice(1);
115
+ };
116
+
117
+ const correctPath = (destination: string, name: string) => {
118
+ if (destination.startsWith('/')) destination = destination.slice(1);
119
+ if (!destination.startsWith('./')) destination = `./${destination}`;
120
+ return path.posix.join(destination, name);
121
+ };
122
+
123
+ const log = (messages: Message[], withoutBreak?: boolean) => {
124
+ if (!withoutBreak) {
125
+ console.log(chalk.yellow(MESSAGE_BRAKE));
126
+ } else {
127
+ console.log(`\n`);
128
+ }
129
+ messages.forEach((message) => console.log(chalk[message.color || 'green'](message.message)));
130
+
131
+ if (!withoutBreak) {
132
+ console.log(chalk.yellow(MESSAGE_BRAKE));
133
+ } else {
134
+ console.log(`\n`);
135
+ }
136
+ };
137
+
138
+ const isPathValid = (path: string) => {
139
+ const isValid = /^(\/?[A-Za-z0-9_-]+)+$/.test(path);
140
+ const pathErrorMessages = [
141
+ { message: `Path ${path} is not valid.`, color: 'red' as const },
142
+ { message: `Please try again.`, color: 'white' as const },
143
+ ];
144
+ if (!isValid) log(pathErrorMessages);
145
+ return isValid;
146
+ };
147
+
148
+ const checkSystem = ({ node: _node }: { node: string }) => {
149
+ const check = checkNodeVersion(_node);
150
+ if ('error' in check) return { error: check.error };
151
+
152
+ const isWindows = process.platform === 'win32';
153
+ const isMacOS = process.platform === 'darwin';
154
+ const isLinux = process.platform === 'linux';
155
+
156
+ if (!isWindows && !isMacOS && !isLinux) return { error: 'Unsupported system.' };
157
+ return { platform: process.platform, node: check.nodeVersion };
158
+ };
159
+
160
+ const checkNodeVersion = (version: string) => {
161
+ const [_major, _minor] = version.split('.');
162
+ const nodeVersion = process.versions.node;
163
+ const [major, minor] = nodeVersion.split('.');
164
+
165
+ if (Number(major) < Number(_major) || (Number(major) === Number(_major) && Number(minor) < Number(_minor))) {
166
+ return {
167
+ error: `You need Node.js version ${chalk.red(
168
+ version,
169
+ )} or higher to run this app. You are currently running Node.js ${chalk.magenta(nodeVersion)}.`,
170
+ };
171
+ }
172
+ return { nodeVersion };
173
+ };
package/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { generateModels } from '@aexol/axolotl-core';
4
+ import { createApp } from './create/index.js';
5
+
6
+ const program = new Command();
7
+
8
+ program
9
+ .name('axolotl')
10
+ .description('CLI for axolotl backend framework, type-safe, schema-first, development.')
11
+ .version('0.0.0');
12
+
13
+ program
14
+ .command('init')
15
+ .description('init axolotl framework')
16
+ .action((str, options) => {
17
+ generateModels({
18
+ schemaPath: './schema.graphql',
19
+ modelsPath: './models.ts',
20
+ });
21
+ });
22
+
23
+ createApp(program);
24
+
25
+ program.parse();
package/jest.config.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ moduleFileExtensions: ['ts', 'tsx', 'js'],
4
+ moduleNameMapper: {
5
+ '@/(.*)': ['<rootDir>/$1'],
6
+ },
7
+ testMatch: ['<rootDir>/**/*.spec.(ts|tsx)'],
8
+ watchPathIgnorePatterns: ['node_modules'],
9
+ watchman: false,
10
+ };
@@ -0,0 +1,12 @@
1
+ export declare const MESSAGE_BRAKE = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
2
+ export declare const BASE_REPOSITORY = "git@github.com:aexol-studio/axolotl.git";
3
+ type T = {
4
+ [key in STARTERS]: {
5
+ example: string;
6
+ repo: `axolotl-starter-${key}`;
7
+ description: string;
8
+ };
9
+ };
10
+ export type STARTERS = 'stucco' | 'yoga';
11
+ export declare const STARTER_DICT: T;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ export const MESSAGE_BRAKE = `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`;
2
+ export const BASE_REPOSITORY = `git@github.com:aexol-studio/axolotl.git`;
3
+ export const STARTER_DICT = {
4
+ stucco: {
5
+ example: 'beerpub',
6
+ repo: 'axolotl-starter-stucco',
7
+ description: 'stucco.js starter',
8
+ },
9
+ yoga: {
10
+ example: 'beerpub-yoga',
11
+ repo: 'axolotl-starter-yoga',
12
+ description: 'GraphQL Yoga starter',
13
+ },
14
+ };
15
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../create/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,qDAAqD,CAAC;AACnF,MAAM,CAAC,MAAM,eAAe,GAAG,yCAAyC,CAAC;AA2BzE,MAAM,CAAC,MAAM,YAAY,GAAM;IAC7B,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,mBAAmB;KACjC;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,sBAAsB;KACpC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const createApp: (program: Command) => void;
@@ -0,0 +1,26 @@
1
+ import chalk from 'chalk';
2
+ import { STARTER_DICT } from './consts.js';
3
+ import { createAppAction } from './utils.js';
4
+ export const createApp = (program) => {
5
+ Object.entries(STARTER_DICT).forEach(([key, { description: _description, repo, example }]) => {
6
+ const starter = key;
7
+ const command = `create-${starter} [dir]`;
8
+ const description = `${chalk.magenta('Axolotl Starter')} - ${_description}`;
9
+ program
10
+ .command(command)
11
+ .description(description)
12
+ .action((destination) => createAppAction({ starter, repo, example, destination }))
13
+ .on('--help', () => {
14
+ console.log('');
15
+ console.log(` ${chalk.magenta('[dir?: string]')} - optional argument, if not provided, starter will be created in ${chalk.red('generated')} directory`);
16
+ console.log('');
17
+ console.log(chalk.gray(`New project in ${chalk.red('generated')} directory`));
18
+ console.log(`$ axolotl create-${starter}`);
19
+ console.log('');
20
+ console.log(chalk.gray(`New project in ${chalk.magenta('passed')} destination`));
21
+ console.log(`$ axolotl create-${starter} test/my-graphql-server`);
22
+ console.log('');
23
+ });
24
+ });
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../create/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC5C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;QAC3F,MAAM,OAAO,GAAG,GAAe,CAAC;QAChC,MAAM,OAAO,GAAG,UAAU,OAAO,QAAQ,CAAC;QAC1C,MAAM,WAAW,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,YAAY,EAAE,CAAC;QAC5E,OAAO;aACJ,OAAO,CAAC,OAAO,CAAC;aAChB,WAAW,CAAC,WAAW,CAAC;aACxB,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;aACjF,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACjB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CACT,KAAK,KAAK,CAAC,OAAO,CAChB,gBAAgB,CACjB,qEAAqE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,CACzG,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;YAC9E,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;YACjF,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,yBAAyB,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const createAppAction: ({ starter, repo, example, destination: _destination, }: {
2
+ starter: string;
3
+ repo: string;
4
+ example: string;
5
+ destination?: string | undefined;
6
+ }) => void;
@@ -0,0 +1,152 @@
1
+ import fs from 'fs';
2
+ import * as path from 'path';
3
+ import { execSync } from 'child_process';
4
+ import chalk from 'chalk';
5
+ import { BASE_REPOSITORY, MESSAGE_BRAKE } from './consts.js';
6
+ export const createAppAction = ({ starter, repo, example, destination: _destination, }) => {
7
+ const destination = _destination ? _destination : './';
8
+ const name = _destination ? '.' : repo;
9
+ const path = correctPath(destination, name);
10
+ const installationMessages = [
11
+ {
12
+ message: `Installing starter ${chalk.magenta('GraphQL Axolotl Server')} - GraphQL ${firstLetterToUpperCase(starter)} example...`,
13
+ },
14
+ { message: `This may take a while...`, color: 'white' },
15
+ ];
16
+ log(installationMessages);
17
+ const trigger = runCommands(path, example);
18
+ if ('success' in trigger) {
19
+ const successMessages = [
20
+ {
21
+ message: `Starter ${chalk.magenta('GraphQL Axolotl Server')} - GraphQL ${firstLetterToUpperCase(starter)} example created.`,
22
+ },
23
+ { message: `To run it, type:`, color: 'white' },
24
+ {
25
+ message: `cd ${chalk.magenta(`${path}`)} && ${chalk.magenta(`npm run start`)}`,
26
+ color: 'yellow',
27
+ },
28
+ ];
29
+ log(successMessages);
30
+ }
31
+ else {
32
+ const errorMessages = [
33
+ { message: `Starter ${chalk.magenta('GraphQL Axolotl Server')} failed.`, color: 'red' },
34
+ { message: ``, color: 'white' },
35
+ { message: `${chalk.yellow('Reason:')} ${trigger.error}`, color: 'white' },
36
+ ];
37
+ log(errorMessages, true);
38
+ process.exit(1);
39
+ }
40
+ };
41
+ function runCommands(path, example) {
42
+ try {
43
+ const system = checkSystem({ node: '16.20' });
44
+ if (system.error)
45
+ return { error: system.error };
46
+ if (fs.existsSync(path))
47
+ return { error: 'folder already exists' };
48
+ if (!isPathValid(path))
49
+ return { error: 'invalid path' };
50
+ if (!runCommand(`git --version`, false))
51
+ return { error: 'git is not installed' };
52
+ const clone = runCommand(`git clone -n --depth=1 --filter=tree:0 ${BASE_REPOSITORY} ${path}`);
53
+ if (!clone)
54
+ return { error: "can't clone repository" };
55
+ const checkout = runCommand(`cd ${path} && git config core.sparseCheckout true && git sparse-checkout set examples/${example} && git checkout && git config core.sparseCheckout false`);
56
+ if (!checkout)
57
+ return { error: "can't clone repository" };
58
+ let copy;
59
+ if (system.platform === 'win32') {
60
+ copy = runCommand(`cd ${path} && xcopy /E /Y examples\\${example} . && rmdir /S /Q examples`);
61
+ }
62
+ else
63
+ copy = runCommand(`cd ${path} && cp -r examples/${example}/* . && rm -rf examples`);
64
+ if (!copy)
65
+ return { error: "can't clone repository" };
66
+ let cleanUpGit;
67
+ if (system.platform === 'win32') {
68
+ cleanUpGit = runCommand(`cd ${path} && rmdir /S /Q .git`);
69
+ }
70
+ else
71
+ cleanUpGit = runCommand(`cd ${path} && rm -rf .git`);
72
+ if (!cleanUpGit)
73
+ return { error: "can't clone repository" };
74
+ runCommand(`cd ${path} && git init --quiet`, false);
75
+ if (!runCommand(`cd ${path} && npm install`))
76
+ return { error: 'problem with installing dependencies' };
77
+ return { success: true };
78
+ }
79
+ catch (error) {
80
+ return { error: 'command failed' };
81
+ }
82
+ }
83
+ const runCommand = (command, withLog = true) => {
84
+ try {
85
+ const stdio = withLog ? 'inherit' : 'ignore';
86
+ execSync(command, { stdio });
87
+ }
88
+ catch (e) {
89
+ if (withLog)
90
+ log([{ message: `Command ${command} failed.`, color: 'red' }]);
91
+ return false;
92
+ }
93
+ return true;
94
+ };
95
+ const firstLetterToUpperCase = (str) => {
96
+ return str.charAt(0).toUpperCase() + str.slice(1);
97
+ };
98
+ const correctPath = (destination, name) => {
99
+ if (destination.startsWith('/'))
100
+ destination = destination.slice(1);
101
+ if (!destination.startsWith('./'))
102
+ destination = `./${destination}`;
103
+ return path.posix.join(destination, name);
104
+ };
105
+ const log = (messages, withoutBreak) => {
106
+ if (!withoutBreak) {
107
+ console.log(chalk.yellow(MESSAGE_BRAKE));
108
+ }
109
+ else {
110
+ console.log(`\n`);
111
+ }
112
+ messages.forEach((message) => console.log(chalk[message.color || 'green'](message.message)));
113
+ if (!withoutBreak) {
114
+ console.log(chalk.yellow(MESSAGE_BRAKE));
115
+ }
116
+ else {
117
+ console.log(`\n`);
118
+ }
119
+ };
120
+ const isPathValid = (path) => {
121
+ const isValid = /^(\/?[A-Za-z0-9_-]+)+$/.test(path);
122
+ const pathErrorMessages = [
123
+ { message: `Path ${path} is not valid.`, color: 'red' },
124
+ { message: `Please try again.`, color: 'white' },
125
+ ];
126
+ if (!isValid)
127
+ log(pathErrorMessages);
128
+ return isValid;
129
+ };
130
+ const checkSystem = ({ node: _node }) => {
131
+ const check = checkNodeVersion(_node);
132
+ if ('error' in check)
133
+ return { error: check.error };
134
+ const isWindows = process.platform === 'win32';
135
+ const isMacOS = process.platform === 'darwin';
136
+ const isLinux = process.platform === 'linux';
137
+ if (!isWindows && !isMacOS && !isLinux)
138
+ return { error: 'Unsupported system.' };
139
+ return { platform: process.platform, node: check.nodeVersion };
140
+ };
141
+ const checkNodeVersion = (version) => {
142
+ const [_major, _minor] = version.split('.');
143
+ const nodeVersion = process.versions.node;
144
+ const [major, minor] = nodeVersion.split('.');
145
+ if (Number(major) < Number(_major) || (Number(major) === Number(_major) && Number(minor) < Number(_minor))) {
146
+ return {
147
+ error: `You need Node.js version ${chalk.red(version)} or higher to run this app. You are currently running Node.js ${chalk.magenta(nodeVersion)}.`,
148
+ };
149
+ }
150
+ return { nodeVersion };
151
+ };
152
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../create/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAgB,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI7D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,OAAO,EACP,WAAW,EAAE,YAAY,GAM1B,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAE5C,MAAM,oBAAoB,GAAG;QAC3B;YACE,OAAO,EAAE,sBAAsB,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC,cAAc,sBAAsB,CACxG,OAAO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E,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { generateModels } from '@aexol/axolotl-core';
4
+ import { createApp } from './create/index.js';
5
+ const program = new Command();
6
+ program
7
+ .name('axolotl')
8
+ .description('CLI for axolotl backend framework, type-safe, schema-first, development.')
9
+ .version('0.0.0');
10
+ program
11
+ .command('init')
12
+ .description('init axolotl framework')
13
+ .action((str, options) => {
14
+ generateModels({
15
+ schemaPath: './schema.graphql',
16
+ modelsPath: './models.ts',
17
+ });
18
+ });
19
+ createApp(program);
20
+ program.parse();
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,0EAA0E,CAAC;KACvF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,wBAAwB,CAAC;KACrC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IACvB,cAAc,CAAC;QACb,UAAU,EAAE,kBAAkB;QAC9B,UAAU,EAAE,aAAa;KAC1B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,SAAS,CAAC,OAAO,CAAC,CAAC;AAEnB,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@aexol/axolotl",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "main": "./lib/index.js",
6
+ "author": "Aexol, Artur Czemiel",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tspc",
10
+ "start": "tspc --watch",
11
+ "lint": "tspc && eslint \"./src/**/*.{ts,js}\" --quiet --fix"
12
+ },
13
+ "bin": {
14
+ "axolotl": "lib/index.js"
15
+ },
16
+ "dependencies": {
17
+ "@aexol/axolotl-core": "^0.0.1",
18
+ "commander": "^11.0.0",
19
+ "graphql-js-tree": "^1.0.6"
20
+ }
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "sourceMap": true,
4
+ "target": "es2022",
5
+ "module": "es2022",
6
+ "moduleResolution": "node",
7
+ "experimentalDecorators": true,
8
+ "declaration": true,
9
+ "incremental": true,
10
+ "removeComments": true,
11
+ "noUnusedLocals": true,
12
+ "strictNullChecks": true,
13
+ "skipLibCheck": true,
14
+ "strict": true,
15
+ "allowSyntheticDefaultImports": true,
16
+ "outDir": "./lib",
17
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
18
+ "rootDir": "./",
19
+ "baseUrl": "./",
20
+ "composite": true,
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ },
24
+ "plugins": [
25
+ {
26
+ "transform": "typescript-transform-paths"
27
+ },
28
+ {
29
+ "transform": "typescript-transform-paths",
30
+ "afterDeclarations": true
31
+ }
32
+ ]
33
+ },
34
+ "exclude": ["lib", "node_modules", "jest.config.js"]
35
+ }