@multiplayer-app/cli 1.3.36 → 2.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/.turbo/turbo-build.log +20 -0
- package/.turbo/turbo-lint.log +5 -0
- package/README.md +150 -30
- package/dist/highlights-eq9cgrbb.scm +604 -0
- package/dist/highlights-ghv9g403.scm +205 -0
- package/dist/highlights-hk7bwhj4.scm +284 -0
- package/dist/highlights-r812a2qc.scm +150 -0
- package/dist/highlights-x6tmsnaa.scm +115 -0
- package/dist/index.js +177124 -0
- package/dist/injections-73j83es3.scm +27 -0
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/eslint.config.js +135 -0
- package/package.json +32 -34
- package/bin/multiplayer-app-cli +0 -116
- package/src/api.js +0 -97
- package/src/commands/deployments/create.js +0 -70
- package/src/commands/releases/create.js +0 -55
- package/src/commands/sourcemaps/upload.js +0 -76
- package/src/helper.js +0 -5
- package/src/index.js +0 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/markdown/injections.scm
|
|
2
|
+
(fenced_code_block
|
|
3
|
+
(info_string
|
|
4
|
+
(language) @_lang)
|
|
5
|
+
(code_fence_content) @injection.content
|
|
6
|
+
(#set-lang-from-info-string! @_lang))
|
|
7
|
+
|
|
8
|
+
((html_block) @injection.content
|
|
9
|
+
(#set! injection.language "html")
|
|
10
|
+
(#set! injection.combined)
|
|
11
|
+
(#set! injection.include-children))
|
|
12
|
+
|
|
13
|
+
((minus_metadata) @injection.content
|
|
14
|
+
(#set! injection.language "yaml")
|
|
15
|
+
(#offset! @injection.content 1 0 -1 0)
|
|
16
|
+
(#set! injection.include-children))
|
|
17
|
+
|
|
18
|
+
((plus_metadata) @injection.content
|
|
19
|
+
(#set! injection.language "toml")
|
|
20
|
+
(#offset! @injection.content 1 0 -1 0)
|
|
21
|
+
(#set! injection.include-children))
|
|
22
|
+
|
|
23
|
+
([
|
|
24
|
+
(inline)
|
|
25
|
+
(pipe_table_cell)
|
|
26
|
+
] @injection.content
|
|
27
|
+
(#set! injection.language "markdown_inline"))
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const tsPlugin = require('@typescript-eslint/eslint-plugin')
|
|
2
|
+
const tsParser = require('@typescript-eslint/parser')
|
|
3
|
+
|
|
4
|
+
// Equivalent to env: { es6: true, node: true, jest: true, mocha: true }
|
|
5
|
+
const envGlobals = {
|
|
6
|
+
// Node.js
|
|
7
|
+
__dirname: 'readonly',
|
|
8
|
+
__filename: 'readonly',
|
|
9
|
+
Buffer: 'readonly',
|
|
10
|
+
clearImmediate: 'readonly',
|
|
11
|
+
clearInterval: 'readonly',
|
|
12
|
+
clearTimeout: 'readonly',
|
|
13
|
+
console: 'readonly',
|
|
14
|
+
exports: 'writable',
|
|
15
|
+
global: 'readonly',
|
|
16
|
+
module: 'writable',
|
|
17
|
+
process: 'readonly',
|
|
18
|
+
require: 'readonly',
|
|
19
|
+
setImmediate: 'readonly',
|
|
20
|
+
setInterval: 'readonly',
|
|
21
|
+
setTimeout: 'readonly',
|
|
22
|
+
URL: 'readonly',
|
|
23
|
+
URLSearchParams: 'readonly',
|
|
24
|
+
// Jest
|
|
25
|
+
afterAll: 'readonly',
|
|
26
|
+
afterEach: 'readonly',
|
|
27
|
+
beforeAll: 'readonly',
|
|
28
|
+
beforeEach: 'readonly',
|
|
29
|
+
describe: 'readonly',
|
|
30
|
+
expect: 'readonly',
|
|
31
|
+
fit: 'readonly',
|
|
32
|
+
it: 'readonly',
|
|
33
|
+
jest: 'readonly',
|
|
34
|
+
test: 'readonly',
|
|
35
|
+
xdescribe: 'readonly',
|
|
36
|
+
xit: 'readonly',
|
|
37
|
+
xtest: 'readonly',
|
|
38
|
+
// Mocha
|
|
39
|
+
after: 'readonly',
|
|
40
|
+
before: 'readonly',
|
|
41
|
+
context: 'readonly',
|
|
42
|
+
mocha: 'readonly',
|
|
43
|
+
run: 'readonly',
|
|
44
|
+
specify: 'readonly',
|
|
45
|
+
suite: 'readonly',
|
|
46
|
+
suiteSetup: 'readonly',
|
|
47
|
+
suiteTeardown: 'readonly',
|
|
48
|
+
xcontext: 'readonly',
|
|
49
|
+
xspecify: 'readonly',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = [
|
|
53
|
+
{
|
|
54
|
+
ignores: [
|
|
55
|
+
'package.json',
|
|
56
|
+
'node_modules/**',
|
|
57
|
+
'clients/**',
|
|
58
|
+
'libs/multiplayer-blocknote-lib/**',
|
|
59
|
+
'**/dist/**',
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parser: tsParser,
|
|
66
|
+
parserOptions: {
|
|
67
|
+
ecmaVersion: 'latest',
|
|
68
|
+
sourceType: 'module',
|
|
69
|
+
},
|
|
70
|
+
globals: envGlobals,
|
|
71
|
+
},
|
|
72
|
+
plugins: {
|
|
73
|
+
'@typescript-eslint': tsPlugin,
|
|
74
|
+
},
|
|
75
|
+
rules: {
|
|
76
|
+
// plugin:@typescript-eslint/eslint-recommended — disables ESLint rules
|
|
77
|
+
// that TypeScript handles natively, enables TS-aware replacements
|
|
78
|
+
'constructor-super': 'off',
|
|
79
|
+
'getter-return': 'off',
|
|
80
|
+
'no-const-assign': 'off',
|
|
81
|
+
'no-dupe-args': 'off',
|
|
82
|
+
'no-dupe-class-members': 'off',
|
|
83
|
+
'no-dupe-keys': 'off',
|
|
84
|
+
'no-func-assign': 'off',
|
|
85
|
+
'no-import-assign': 'off',
|
|
86
|
+
'no-new-symbol': 'off',
|
|
87
|
+
'no-obj-calls': 'off',
|
|
88
|
+
'no-redeclare': 'off',
|
|
89
|
+
'no-setter-return': 'off',
|
|
90
|
+
'no-this-before-super': 'off',
|
|
91
|
+
'no-undef': 'off',
|
|
92
|
+
'no-unreachable': 'off',
|
|
93
|
+
'no-unsafe-negation': 'off',
|
|
94
|
+
'no-var': 'error',
|
|
95
|
+
'prefer-rest-params': 'error',
|
|
96
|
+
'prefer-spread': 'error',
|
|
97
|
+
// plugin:@typescript-eslint/recommended
|
|
98
|
+
'@typescript-eslint/ban-ts-comment': 'error',
|
|
99
|
+
'no-array-constructor': 'off',
|
|
100
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
101
|
+
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
|
102
|
+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
|
103
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
104
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
|
105
|
+
'@typescript-eslint/no-this-alias': 'error',
|
|
106
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
|
107
|
+
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
108
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
109
|
+
'@typescript-eslint/prefer-as-const': 'error',
|
|
110
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
111
|
+
// Custom rules (from .eslintrc)
|
|
112
|
+
'prefer-const': 'error',
|
|
113
|
+
'@typescript-eslint/no-namespace': 0,
|
|
114
|
+
'@typescript-eslint/prefer-namespace-keyword': 0,
|
|
115
|
+
'@typescript-eslint/no-empty-function': 0,
|
|
116
|
+
'@typescript-eslint/no-unused-vars': 0,
|
|
117
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
118
|
+
'block-spacing': ['error', 'always'],
|
|
119
|
+
'keyword-spacing': ['error', { before: true, after: true }],
|
|
120
|
+
'indent': ['error', 2, { SwitchCase: 1 }],
|
|
121
|
+
'linebreak-style': ['error', 'unix'],
|
|
122
|
+
'quotes': ['error', 'single'],
|
|
123
|
+
'semi': ['error', 'never'],
|
|
124
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
125
|
+
'no-console': 1,
|
|
126
|
+
'object-curly-spacing': ['error', 'always'],
|
|
127
|
+
'space-in-parens': ['error', 'never'],
|
|
128
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
129
|
+
'no-trailing-spaces': 'error',
|
|
130
|
+
'no-multi-spaces': 'error',
|
|
131
|
+
'no-lonely-if': 'error',
|
|
132
|
+
'key-spacing': 'error',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
]
|
package/package.json
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Multiplayer CLI",
|
|
5
|
-
"
|
|
6
|
-
"name": "Multiplayer Software, Inc.",
|
|
7
|
-
"url": "https://www.multiplayer.app"
|
|
8
|
-
},
|
|
9
|
-
"private": false,
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/multiplayer-app/multiplayer-session-recorder-javascript/issues"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/multiplayer-app/multiplayer-session-recorder-javascript.git"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"type": "module",
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=18",
|
|
21
|
-
"npm": ">=8"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"multiplayer",
|
|
25
|
-
"api",
|
|
26
|
-
"release",
|
|
27
|
-
"sourcemap",
|
|
28
|
-
"deployment"
|
|
29
|
-
],
|
|
30
|
-
"main": "src/index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
31
6
|
"bin": {
|
|
32
|
-
"multiplayer
|
|
7
|
+
"multiplayer": "./dist/index.js"
|
|
33
8
|
},
|
|
34
9
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
10
|
+
"build": "bun build src/index.tsx --outdir dist --target bun --format esm --sourcemap=none && rm -f dist/index.js.map",
|
|
11
|
+
"start": "bun dist/index.js",
|
|
12
|
+
"dev": "bun src/index.tsx",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"lint": "eslint src/**/*.ts --config eslint.config.js",
|
|
15
|
+
"prepublish": "npm run build"
|
|
38
16
|
},
|
|
17
|
+
"license": "MIT",
|
|
39
18
|
"dependencies": {
|
|
19
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.73",
|
|
20
|
+
"@anthropic-ai/sdk": "^0.78.0",
|
|
21
|
+
"@opentui/core": "0.1.93",
|
|
22
|
+
"@opentui/react": "0.1.93",
|
|
23
|
+
"commander": "14.0.3",
|
|
24
|
+
"dotenv": "16.0.0",
|
|
40
25
|
"jsonwebtoken": "9.0.3",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
26
|
+
"mongoose": "9.3.3",
|
|
27
|
+
"openai": "6.33.0",
|
|
28
|
+
"react": "19.2.4",
|
|
29
|
+
"simple-git": "3.33.0",
|
|
30
|
+
"socket.io-client": "4.8.3",
|
|
31
|
+
"superagent": "10.3.0"
|
|
32
|
+
},
|
|
33
|
+
"overrides": {
|
|
34
|
+
"react": "19.2.4"
|
|
43
35
|
},
|
|
44
36
|
"devDependencies": {
|
|
45
|
-
"
|
|
37
|
+
"@sindresorhus/tsconfig": "^8.1.0",
|
|
38
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
39
|
+
"@types/node": "25.5.0",
|
|
40
|
+
"@types/react": "19.2.14",
|
|
41
|
+
"@types/superagent": "8.1.9",
|
|
42
|
+
"eslint": "10.1.0",
|
|
43
|
+
"typescript": "6.0.2"
|
|
46
44
|
}
|
|
47
45
|
}
|
package/bin/multiplayer-app-cli
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import yargs from 'yargs'
|
|
4
|
-
import { hideBin } from 'yargs/helpers'
|
|
5
|
-
import { create as createRelease } from '../src/commands/releases/create.js'
|
|
6
|
-
import { create as createDeployment } from '../src/commands/deployments/create.js'
|
|
7
|
-
import { upload as uploadSourcemap } from '../src/commands/sourcemaps/upload.js'
|
|
8
|
-
|
|
9
|
-
function handleResult(err, response) {
|
|
10
|
-
if (err) {
|
|
11
|
-
if (err.status) console.error('Status Code:', err.status)
|
|
12
|
-
if (err.response) console.error(err.response.text)
|
|
13
|
-
else console.error(err.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
} else {
|
|
16
|
-
console.log(JSON.stringify(response, null, 2))
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
yargs(hideBin(process.argv))
|
|
21
|
-
.command('releases', 'Manage releases', (yargs) => {
|
|
22
|
-
yargs.command(
|
|
23
|
-
'create',
|
|
24
|
-
'Create a release',
|
|
25
|
-
(yargs) => yargs
|
|
26
|
-
.option('apiKey', { describe: 'Multiplayer personal user API key (MULTIPLAYER_API_KEY)', type: 'string' })
|
|
27
|
-
.option('service', { describe: 'Service name (SERVICE_NAME)', type: 'string' })
|
|
28
|
-
.option('releaseVersion', { describe: 'Release version (RELEASE)', type: 'string' })
|
|
29
|
-
.option('commitHash', { describe: 'Commit hash (COMMIT_HASH)', type: 'string' })
|
|
30
|
-
.option('repositoryUrl', { describe: 'Repository URL (REPOSITORY_URL)', type: 'string' })
|
|
31
|
-
.option('releaseNotes', { describe: '[Optional] Release notes (RELEASE_NOTES)', type: 'string' })
|
|
32
|
-
.option('baseUrl', { describe: '[Optional] Base URL (BASE_URL)', type: 'string' }),
|
|
33
|
-
(argv) => {
|
|
34
|
-
|
|
35
|
-
const options = {
|
|
36
|
-
apiKey: argv.apiKey || process.env.MULTIPLAYER_API_KEY,
|
|
37
|
-
service: argv.service || process.env.SERVICE_NAME,
|
|
38
|
-
release: argv.release || process.env.RELEASE,
|
|
39
|
-
commitHash: argv.commitHash || process.env.COMMIT_HASH,
|
|
40
|
-
repositoryUrl: argv.repositoryUrl || process.env.REPOSITORY_URL,
|
|
41
|
-
releaseNotes: argv.releaseNotes || process.env.RELEASE_NOTES,
|
|
42
|
-
baseUrl: argv.baseUrl || process.env.BASE_URL,
|
|
43
|
-
}
|
|
44
|
-
if (!options.apiKey) return exitWithError('A Multiplayer personal user API key is required.', yargs)
|
|
45
|
-
if (!options.service) return exitWithError('A service name is required.', yargs)
|
|
46
|
-
if (!options.release) return exitWithError('A release is required.', yargs)
|
|
47
|
-
createRelease(options, handleResult)
|
|
48
|
-
},
|
|
49
|
-
)
|
|
50
|
-
.demandCommand()
|
|
51
|
-
.help()
|
|
52
|
-
})
|
|
53
|
-
.command('deployments', 'Manage deployments', (yargs) => {
|
|
54
|
-
yargs.command(
|
|
55
|
-
'create',
|
|
56
|
-
'Create a deployment',
|
|
57
|
-
(yargs) => yargs
|
|
58
|
-
.option('apiKey', { describe: 'Multiplayer personal user API key (MULTIPLAYER_API_KEY)', type: 'string' })
|
|
59
|
-
.option('service', { describe: 'Service name (SERVICE_NAME)', type: 'string' })
|
|
60
|
-
.option('release', { describe: 'Service release (RELEASE)', type: 'string' })
|
|
61
|
-
.option('environment', { describe: 'Environment name (ENVIRONMENT)', type: 'string' })
|
|
62
|
-
.option('baseUrl', { describe: '[Optional] Base URL (BASE_URL)', type: 'string' }),
|
|
63
|
-
(argv) => {
|
|
64
|
-
const options = {
|
|
65
|
-
apiKey: argv.apiKey || process.env.MULTIPLAYER_API_KEY,
|
|
66
|
-
service: argv.service || process.env.SERVICE_NAME,
|
|
67
|
-
release: argv.release || process.env.VERSION,
|
|
68
|
-
environment: argv.environment || process.env.ENVIRONMENT,
|
|
69
|
-
baseUrl: argv.baseUrl || process.env.BASE_URL,
|
|
70
|
-
}
|
|
71
|
-
if (!options.apiKey) return exitWithError('A Multiplayer personal user API key is required.', yargs)
|
|
72
|
-
if (!options.service) return exitWithError('A service name is required.', yargs)
|
|
73
|
-
if (!options.release) return exitWithError('A version is required.', yargs)
|
|
74
|
-
if (!options.environment) return exitWithError('A environment is required.', yargs)
|
|
75
|
-
createDeployment(options, handleResult)
|
|
76
|
-
},
|
|
77
|
-
)
|
|
78
|
-
.demandCommand()
|
|
79
|
-
.help()
|
|
80
|
-
})
|
|
81
|
-
.command('sourcemaps', 'Manage sourcemaps', (yargs) => {
|
|
82
|
-
yargs.command(
|
|
83
|
-
'upload <directories...>',
|
|
84
|
-
'Upload sourcemaps from a directory',
|
|
85
|
-
(yargs) => yargs
|
|
86
|
-
.positional('directories', { describe: 'Path to directory containing sourcemap files' })
|
|
87
|
-
.option('apiKey', { describe: 'Multiplayer personal user API key (MULTIPLAYER_API_KEY)', type: 'string' })
|
|
88
|
-
.option('service', { describe: 'Service name (SERVICE_NAME)', type: 'string' })
|
|
89
|
-
.option('release', { describe: 'Service release (RELEASE)', type: 'string' })
|
|
90
|
-
.option('baseUrl', { describe: '[Optional] Base URL (BASE_URL)', type: 'string' }),
|
|
91
|
-
(argv) => {
|
|
92
|
-
const options = {
|
|
93
|
-
apiKey: argv.apiKey || process.env.MULTIPLAYER_API_KEY,
|
|
94
|
-
service: argv.service || process.env.SERVICE_NAME,
|
|
95
|
-
release: argv.release || process.env.RELEASE,
|
|
96
|
-
baseUrl: argv.baseUrl || process.env.BASE_URL,
|
|
97
|
-
}
|
|
98
|
-
if (!options.apiKey) return exitWithError('A Multiplayer personal user API key is required.', yargs)
|
|
99
|
-
if (!options.service) return exitWithError('A service name is required.', yargs)
|
|
100
|
-
if (!options.release) return exitWithError('A release is required.', yargs)
|
|
101
|
-
|
|
102
|
-
uploadSourcemap(argv.directories, options, handleResult)
|
|
103
|
-
},
|
|
104
|
-
)
|
|
105
|
-
.demandCommand()
|
|
106
|
-
.help()
|
|
107
|
-
})
|
|
108
|
-
.demandCommand()
|
|
109
|
-
.help()
|
|
110
|
-
.parse()
|
|
111
|
-
|
|
112
|
-
function exitWithError(message, yargsInstance) {
|
|
113
|
-
yargsInstance.showHelp()
|
|
114
|
-
console.error(message)
|
|
115
|
-
process.exit(1)
|
|
116
|
-
}
|
package/src/api.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import superagent from 'superagent'
|
|
2
|
-
|
|
3
|
-
const MULTIPLAYER_BASE_API_URL = 'https://api.multiplayer.app/v0'
|
|
4
|
-
|
|
5
|
-
export const getDefaultBranchId = async (
|
|
6
|
-
apiKey,
|
|
7
|
-
workspaceId,
|
|
8
|
-
projectId,
|
|
9
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
10
|
-
) => {
|
|
11
|
-
const response = await superagent.get(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/branches/default`)
|
|
12
|
-
.set('x-api-key', apiKey)
|
|
13
|
-
|
|
14
|
-
return response.body?._id
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const getEntityId = async (
|
|
18
|
-
apiKey,
|
|
19
|
-
workspaceId,
|
|
20
|
-
projectId,
|
|
21
|
-
branchId,
|
|
22
|
-
entityName,
|
|
23
|
-
entityType,
|
|
24
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
25
|
-
) => {
|
|
26
|
-
const response = await superagent.get(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/branches/${branchId}/entities?key=${entityName}&type=${entityType}&limit=1&skip=0`)
|
|
27
|
-
.set('x-api-key', apiKey)
|
|
28
|
-
|
|
29
|
-
const entityId = response.body?.data?.[0]?.entityId
|
|
30
|
-
if (!entityId) {
|
|
31
|
-
throw new Error(`Entity ${entityName} not found`)
|
|
32
|
-
}
|
|
33
|
-
return entityId
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const createRelease = async (
|
|
37
|
-
apiKey,
|
|
38
|
-
workspaceId,
|
|
39
|
-
projectId,
|
|
40
|
-
payload,
|
|
41
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
42
|
-
) => {
|
|
43
|
-
const response = await superagent.post(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/releases`)
|
|
44
|
-
.set('x-api-key', apiKey)
|
|
45
|
-
.send(payload)
|
|
46
|
-
|
|
47
|
-
return response.body
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const getReleaseId = async (
|
|
51
|
-
apiKey,
|
|
52
|
-
workspaceId,
|
|
53
|
-
projectId,
|
|
54
|
-
entityId,
|
|
55
|
-
version,
|
|
56
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
57
|
-
) => {
|
|
58
|
-
const response = await superagent.get(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/releases?version=${version}&entity=${entityId}`)
|
|
59
|
-
.set('x-api-key', apiKey)
|
|
60
|
-
|
|
61
|
-
const versionId = response.body?.data?.[0]?._id
|
|
62
|
-
if (!versionId) {
|
|
63
|
-
throw new Error(`Version ${version} not found`)
|
|
64
|
-
}
|
|
65
|
-
return versionId
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const createDeployment = async (
|
|
69
|
-
apiKey,
|
|
70
|
-
workspaceId,
|
|
71
|
-
projectId,
|
|
72
|
-
payload,
|
|
73
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
74
|
-
) => {
|
|
75
|
-
const response = await superagent.post(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/deployments`)
|
|
76
|
-
.set('x-api-key', apiKey)
|
|
77
|
-
.send(payload)
|
|
78
|
-
|
|
79
|
-
return response.body
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const uploadSourcemap = async (
|
|
83
|
-
apiKey,
|
|
84
|
-
workspaceId,
|
|
85
|
-
projectId,
|
|
86
|
-
releaseId,
|
|
87
|
-
filePath,
|
|
88
|
-
stream,
|
|
89
|
-
baseUrl = MULTIPLAYER_BASE_API_URL,
|
|
90
|
-
) => {
|
|
91
|
-
const response = await superagent.post(`${baseUrl}/version/workspaces/${workspaceId}/projects/${projectId}/releases/${releaseId}/sourcemaps`)
|
|
92
|
-
.set('x-api-key', apiKey)
|
|
93
|
-
.set('Content-disposition', `attachment; filename=${filePath}`)
|
|
94
|
-
.attach('file', stream, filePath)
|
|
95
|
-
|
|
96
|
-
return response.body
|
|
97
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as API from '../../api.js'
|
|
2
|
-
import { decodeJwtToken } from '../../helper.js'
|
|
3
|
-
|
|
4
|
-
export const create = async (options, callback) => {
|
|
5
|
-
try {
|
|
6
|
-
const {
|
|
7
|
-
apiKey,
|
|
8
|
-
service,
|
|
9
|
-
release,
|
|
10
|
-
environment,
|
|
11
|
-
baseUrl,
|
|
12
|
-
} = options
|
|
13
|
-
|
|
14
|
-
const jwtToken = decodeJwtToken(apiKey) || {}
|
|
15
|
-
|
|
16
|
-
const branchId = await API.getDefaultBranchId(
|
|
17
|
-
apiKey,
|
|
18
|
-
jwtToken.workspace,
|
|
19
|
-
jwtToken.project,
|
|
20
|
-
baseUrl,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const serviceId = await API.getEntityId(
|
|
24
|
-
apiKey,
|
|
25
|
-
jwtToken.workspace,
|
|
26
|
-
jwtToken.project,
|
|
27
|
-
branchId,
|
|
28
|
-
service,
|
|
29
|
-
'platform_component',
|
|
30
|
-
baseUrl,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const releaseId = await API.getReleaseId(
|
|
34
|
-
apiKey,
|
|
35
|
-
jwtToken.workspace,
|
|
36
|
-
jwtToken.project,
|
|
37
|
-
serviceId,
|
|
38
|
-
release,
|
|
39
|
-
baseUrl,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const environmentId = await API.getEntityId(
|
|
43
|
-
apiKey,
|
|
44
|
-
jwtToken.workspace,
|
|
45
|
-
jwtToken.project,
|
|
46
|
-
branchId,
|
|
47
|
-
environment,
|
|
48
|
-
'environment',
|
|
49
|
-
baseUrl,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
await API.createDeployment(
|
|
53
|
-
apiKey,
|
|
54
|
-
jwtToken.workspace,
|
|
55
|
-
jwtToken.project,
|
|
56
|
-
{
|
|
57
|
-
entity: serviceId,
|
|
58
|
-
release: releaseId,
|
|
59
|
-
environment: environmentId,
|
|
60
|
-
},
|
|
61
|
-
baseUrl,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
callback(null, {
|
|
65
|
-
message: 'Deployment created successfully',
|
|
66
|
-
})
|
|
67
|
-
} catch (err) {
|
|
68
|
-
callback(err, null)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as API from '../../api.js'
|
|
2
|
-
import { decodeJwtToken } from '../../helper.js'
|
|
3
|
-
|
|
4
|
-
export const create = async (options, callback) => {
|
|
5
|
-
try {
|
|
6
|
-
const {
|
|
7
|
-
apiKey,
|
|
8
|
-
service,
|
|
9
|
-
release,
|
|
10
|
-
commitHash,
|
|
11
|
-
repositoryUrl,
|
|
12
|
-
releaseNotes,
|
|
13
|
-
baseUrl,
|
|
14
|
-
} = options
|
|
15
|
-
|
|
16
|
-
const jwtToken = decodeJwtToken(apiKey) || {}
|
|
17
|
-
|
|
18
|
-
const branchId = await API.getDefaultBranchId(
|
|
19
|
-
apiKey,
|
|
20
|
-
jwtToken.workspace,
|
|
21
|
-
jwtToken.project,
|
|
22
|
-
baseUrl,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
const serviceId = await API.getEntityId(
|
|
26
|
-
apiKey,
|
|
27
|
-
jwtToken.workspace,
|
|
28
|
-
jwtToken.project,
|
|
29
|
-
branchId,
|
|
30
|
-
service,
|
|
31
|
-
'platform_component',
|
|
32
|
-
baseUrl,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
await API.createRelease(
|
|
36
|
-
apiKey,
|
|
37
|
-
jwtToken.workspace,
|
|
38
|
-
jwtToken.project,
|
|
39
|
-
{
|
|
40
|
-
entity: serviceId,
|
|
41
|
-
version: release,
|
|
42
|
-
releaseNotes: releaseNotes || '',
|
|
43
|
-
commitHash,
|
|
44
|
-
repositoryUrl,
|
|
45
|
-
},
|
|
46
|
-
baseUrl,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
callback(null, {
|
|
50
|
-
message: 'Release created successfully',
|
|
51
|
-
})
|
|
52
|
-
} catch (err) {
|
|
53
|
-
callback(err, null)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import * as API from '../../api.js'
|
|
4
|
-
import { decodeJwtToken } from '../../helper.js'
|
|
5
|
-
|
|
6
|
-
const collectSourcemaps = (dir) => {
|
|
7
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true })
|
|
8
|
-
const files = []
|
|
9
|
-
|
|
10
|
-
for (const entry of entries) {
|
|
11
|
-
const fullPath = path.join(dir, entry.name)
|
|
12
|
-
if (entry.isDirectory()) {
|
|
13
|
-
files.push(...collectSourcemaps(fullPath))
|
|
14
|
-
} else if (entry.isFile() && entry.name.endsWith('.map')) {
|
|
15
|
-
files.push(fullPath)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return files
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const upload = async (directories, options, callback) => {
|
|
22
|
-
try {
|
|
23
|
-
const { apiKey, service, release, baseUrl } = options
|
|
24
|
-
|
|
25
|
-
const jwtToken = decodeJwtToken(apiKey) || {}
|
|
26
|
-
|
|
27
|
-
const branchId = await API.getDefaultBranchId(
|
|
28
|
-
apiKey,
|
|
29
|
-
jwtToken.workspace,
|
|
30
|
-
jwtToken.project,
|
|
31
|
-
baseUrl,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
const serviceId = await API.getEntityId(
|
|
35
|
-
apiKey,
|
|
36
|
-
jwtToken.workspace,
|
|
37
|
-
jwtToken.project,
|
|
38
|
-
branchId,
|
|
39
|
-
service,
|
|
40
|
-
'platform_component',
|
|
41
|
-
baseUrl,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
const releaseId = await API.getReleaseId(
|
|
45
|
-
apiKey,
|
|
46
|
-
jwtToken.workspace,
|
|
47
|
-
jwtToken.project,
|
|
48
|
-
serviceId,
|
|
49
|
-
release,
|
|
50
|
-
baseUrl,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
const files = directories.flatMap(collectSourcemaps)
|
|
54
|
-
|
|
55
|
-
if (files.length === 0) {
|
|
56
|
-
return callback(new Error(`No sourcemap files found in directories: ${directories.join(', ')}`), null)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for (const filePath of files) {
|
|
60
|
-
const stream = fs.createReadStream(filePath)
|
|
61
|
-
await API.uploadSourcemap(
|
|
62
|
-
apiKey,
|
|
63
|
-
jwtToken.workspace,
|
|
64
|
-
jwtToken.project,
|
|
65
|
-
releaseId,
|
|
66
|
-
filePath,
|
|
67
|
-
stream,
|
|
68
|
-
baseUrl,
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
callback(null, { message: `Uploaded ${files.length} sourcemap(s) successfully` })
|
|
73
|
-
} catch (err) {
|
|
74
|
-
callback(err, null)
|
|
75
|
-
}
|
|
76
|
-
}
|
package/src/helper.js
DELETED
package/src/index.js
DELETED