neutrinos-cli 1.0.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/.configs/auth.json +5 -0
- package/.configs/preferences.json +5 -0
- package/.env +6 -0
- package/README.md +173 -0
- package/bin/cli.js +239 -0
- package/cli-auth/auth.js +54 -0
- package/cli-auth/publish.js +7 -0
- package/cli-auth/server.js +44 -0
- package/cli-auth/services/auth-utils.js +68 -0
- package/commands/alpha-publish.js +219 -0
- package/commands/attribute.js +155 -0
- package/commands/build.js +83 -0
- package/commands/deprecate.js +88 -0
- package/commands/dev.js +21 -0
- package/commands/generate.js +19 -0
- package/commands/new-workspace.js +142 -0
- package/commands/publish.js +334 -0
- package/commands/select-packages.mjs +36 -0
- package/commands/serve.js +27 -0
- package/package.json +34 -0
- package/setup.js +55 -0
- package/templates/assets/default-icon.png +0 -0
- package/templates/component/.component.ts.hbs +126 -0
- package/templates/component/.spec.ts.hbs +15 -0
- package/templates/component/.styles.ts.hbs +2 -0
- package/templates/module/.module.js.hbs +11 -0
- package/templates/plugins-server/index.js +18 -0
- package/templates/project/.vscode/extensions.json +6 -0
- package/templates/project/ATTRIBUTE.md +127 -0
- package/templates/project/Dockerfile +15 -0
- package/templates/project/helmchart/.helmignore +23 -0
- package/templates/project/helmchart/Chart.yaml +24 -0
- package/templates/project/helmchart/templates/NOTES.txt +22 -0
- package/templates/project/helmchart/templates/_helpers.tpl +62 -0
- package/templates/project/helmchart/templates/deployment.yaml +69 -0
- package/templates/project/helmchart/templates/ingress.yaml +62 -0
- package/templates/project/helmchart/templates/service.yaml +14 -0
- package/templates/project/helmchart/values.yaml +74 -0
- package/templates/project/index.html +24 -0
- package/templates/project/index.ts +86 -0
- package/templates/project/public-api.ts +0 -0
- package/templates/project/tsconfig.json +27 -0
- package/utils/attribute-utils.js +149 -0
- package/utils/check-valid-ws.js +21 -0
- package/utils/copy-utils.js +68 -0
- package/utils/create-client.js +23 -0
- package/utils/file-utils.js +43 -0
- package/utils/generate-component.js +101 -0
- package/utils/generate-module.js +51 -0
- package/utils/get-package-info.js +53 -0
- package/utils/get-packages.js +15 -0
- package/utils/inquirer-utils.js +49 -0
- package/utils/logger.js +35 -0
- package/utils/marketplace-api-utils.js +34 -0
- package/utils/path-utils.js +40 -0
- package/utils/prettify.js +36 -0
- package/utils/user-seesion-utils.js +43 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
export const inquiry = async (queries) => {
|
|
4
|
+
try {
|
|
5
|
+
const answers = await inquirer.prompt(queries);
|
|
6
|
+
return answers;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(error);
|
|
9
|
+
return error;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const multipleInquiry = async (query, field) => {
|
|
14
|
+
const result = [];
|
|
15
|
+
let addMore = true;
|
|
16
|
+
while (addMore) {
|
|
17
|
+
const value = await inquiry(query);
|
|
18
|
+
if (!value) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
addMore = (
|
|
22
|
+
await inquiry({
|
|
23
|
+
type: 'confirm',
|
|
24
|
+
name: 'continueAdding',
|
|
25
|
+
message: 'Do you want to add another ' + field + '?',
|
|
26
|
+
default: true,
|
|
27
|
+
})
|
|
28
|
+
).continueAdding;
|
|
29
|
+
result.push(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const DISPLAY_NAME_QUERY = {
|
|
36
|
+
type: 'input',
|
|
37
|
+
name: 'name',
|
|
38
|
+
message: 'Enter the Display Name of the package :',
|
|
39
|
+
};
|
|
40
|
+
export const ICON_FILE_PATH_QUERY = {
|
|
41
|
+
type: 'input',
|
|
42
|
+
name: 'value',
|
|
43
|
+
message: 'Enter the path to the icon of the package :',
|
|
44
|
+
};
|
|
45
|
+
export const IMAGES_FILE_PATH_QUERY = {
|
|
46
|
+
type: 'input',
|
|
47
|
+
name: 'value',
|
|
48
|
+
message: 'Enter the path to images of the package :',
|
|
49
|
+
};
|
package/utils/logger.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { greenBright, red, yellow, yellowBright } from 'colorette';
|
|
2
|
+
import { log as _log, error } from 'node:console';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Logs a message with green color to indicate that it is successful.
|
|
6
|
+
* @param {string} message - The message to be logged.
|
|
7
|
+
*/
|
|
8
|
+
export const log = (message) => _log(yellow(message));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Logs a message with blue color to indicate that it is in progress.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} message - The message to be logged.
|
|
14
|
+
*/
|
|
15
|
+
export const inprogress = (message) => _log(yellowBright(message));
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Logs a success message with a checkmark symbol.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} message - The message to be logged.
|
|
21
|
+
*/
|
|
22
|
+
export const done = (message) => _log(greenBright('✔ ' + message));
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Logs a failed message and error.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} message - The message to log.
|
|
28
|
+
* @param {Error} [err] - The error to log.
|
|
29
|
+
*/
|
|
30
|
+
export const failed = (message, err) => {
|
|
31
|
+
error(red('✖ ' + message));
|
|
32
|
+
if (err) {
|
|
33
|
+
error(err);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {any} form
|
|
7
|
+
* @param {string} path
|
|
8
|
+
* @param {any} session
|
|
9
|
+
* @param {boolean} isProdPublish
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export const publishToMarketplace = async (form, path, session, isProdPublish) => {
|
|
13
|
+
const url = (isProdPublish ? process.env.MARKETPLACE_URL_PROD : process.env.MARKETPLACE_URL) + path;
|
|
14
|
+
|
|
15
|
+
const config = {
|
|
16
|
+
method: 'post',
|
|
17
|
+
maxBodyLength: Infinity,
|
|
18
|
+
url,
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
'Content-Type': 'multipart/form-data',
|
|
22
|
+
Authorization: `${session.token_type} ${session.access_token}`,
|
|
23
|
+
},
|
|
24
|
+
data: form,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const response = await axios.request(config);
|
|
29
|
+
return response.data;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
throw new Error(e.response?.data?.message || e.response?.message || e.message);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import { kebabCase, pascalCase } from 'change-case';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
export const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
+
export const templatesPath = () => {
|
|
9
|
+
return join(__dirname, '../templates');
|
|
10
|
+
};
|
|
11
|
+
export const componentTemplatesPath = () => {
|
|
12
|
+
return join(templatesPath(), 'component');
|
|
13
|
+
};
|
|
14
|
+
export const pluginJsonPath = (dir) => {
|
|
15
|
+
return join(dir, 'plugin.json');
|
|
16
|
+
};
|
|
17
|
+
export const modulesTemplatesPath = () => {
|
|
18
|
+
return join(templatesPath(), 'module');
|
|
19
|
+
};
|
|
20
|
+
export const pluginServerRoot = (wsPath) => {
|
|
21
|
+
return join(wsPath, 'plugins-server');
|
|
22
|
+
};
|
|
23
|
+
export const pluginServerTemplatesPath = () => {
|
|
24
|
+
return join(templatesPath(), 'plugins-server');
|
|
25
|
+
};
|
|
26
|
+
export const configDir = () => {
|
|
27
|
+
return join(homedir(), '.alphaconfigs');
|
|
28
|
+
};
|
|
29
|
+
export const authConfigJson = () => {
|
|
30
|
+
return join(configDir(), 'auth.json');
|
|
31
|
+
};
|
|
32
|
+
export const getGeneratedComponentName = (packageName) => {
|
|
33
|
+
return kebabCase(packageName);
|
|
34
|
+
};
|
|
35
|
+
export const getGeneratedComponentClassName = (packageName) => {
|
|
36
|
+
return pascalCase(packageName);
|
|
37
|
+
};
|
|
38
|
+
export const getDefaultIconPath = () => {
|
|
39
|
+
return join(templatesPath(), 'assets/default-icon.png');
|
|
40
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { format } from 'prettier';
|
|
2
|
+
|
|
3
|
+
/**@type {import('prettier').Options} */
|
|
4
|
+
const formatOptions = {
|
|
5
|
+
printWidth: 80,
|
|
6
|
+
singleQuote: true,
|
|
7
|
+
quoteProps: 'as-needed',
|
|
8
|
+
trailingComma: 'es5',
|
|
9
|
+
// useTabs: true,
|
|
10
|
+
tabWidth: 4,
|
|
11
|
+
semi: true,
|
|
12
|
+
bracketSpacing: true,
|
|
13
|
+
arrowParens: 'avoid',
|
|
14
|
+
/**
|
|
15
|
+
By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer,
|
|
16
|
+
e.g. GitHub comment and BitBucket. In some cases you may want to rely on editor/viewer soft wrapping instead,
|
|
17
|
+
so this option allows you to opt out with "never".
|
|
18
|
+
Valid options:
|
|
19
|
+
"always" - Wrap prose if it exceeds the print width.
|
|
20
|
+
"never" - Do not wrap prose.
|
|
21
|
+
"preserve" - Wrap prose as-is.
|
|
22
|
+
*/
|
|
23
|
+
// proseWrap: "<always|never|preserve>"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Prettify the given code
|
|
28
|
+
* @param {string | Object} code
|
|
29
|
+
* @param {import('prettier').LiteralUnion<import('prettier').BuiltInParserName>} [parser]
|
|
30
|
+
* @returns {Promise<string>}
|
|
31
|
+
*/
|
|
32
|
+
export const prettify = (code, parser) =>
|
|
33
|
+
format(typeof code === 'string' ? code : JSON.stringify(code, null, 2), {
|
|
34
|
+
...formatOptions,
|
|
35
|
+
parser: parser || 'typescript',
|
|
36
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { exit } from 'process';
|
|
4
|
+
import { createClient } from './create-client.js';
|
|
5
|
+
import { failed, log } from './logger.js';
|
|
6
|
+
import { authConfigJson } from './path-utils.js';
|
|
7
|
+
|
|
8
|
+
export const validateUserLogin = async () => {
|
|
9
|
+
try {
|
|
10
|
+
const tokenSetPath = authConfigJson();
|
|
11
|
+
if (!existsSync(tokenSetPath)) {
|
|
12
|
+
log('Please Login');
|
|
13
|
+
exit(1);
|
|
14
|
+
}
|
|
15
|
+
const client = await createClient();
|
|
16
|
+
const response = await verifyToken(client, tokenSetPath);
|
|
17
|
+
if (response.active) {
|
|
18
|
+
return true;
|
|
19
|
+
} else {
|
|
20
|
+
await refreshToken(client, tokenSetPath);
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
failed('Please login again');
|
|
25
|
+
exit(1);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getLoggedInUserSession = async () => {
|
|
30
|
+
await validateUserLogin();
|
|
31
|
+
return JSON.parse(readFileSync(authConfigJson(), 'utf-8'));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const verifyToken = async (client, tokenSetPath) => {
|
|
35
|
+
const tokenSet = JSON.parse(readFileSync(tokenSetPath, 'utf-8'));
|
|
36
|
+
return await client.introspect(tokenSet.access_token);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const refreshToken = async (client, tokenSetPath) => {
|
|
40
|
+
const tokenSet = JSON.parse(readFileSync(tokenSetPath, 'utf-8'));
|
|
41
|
+
const updatedTokenSet = await client.refresh(tokenSet.refresh_token);
|
|
42
|
+
writeFileSync(tokenSetPath, JSON.stringify(updatedTokenSet, null, 2));
|
|
43
|
+
};
|