Skip to content

Commit aa11bff

Browse files
authored
chore: add script to import test connections (#2612)
* chore: add script to import test connections * move scripts to package + fix eslint * use uuidv5 and prompt * regen package-lock
1 parent 1b22bad commit aa11bff

24 files changed

+785
-435
lines changed

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"packages": ["packages/*", "configs/*"],
2+
"packages": ["packages/*", "configs/*", "scripts"],
33
"version": "independent"
44
}

package-lock.json

+109-181
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-10
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,8 @@
5353
"devDependencies": {
5454
"@testing-library/dom": "^8.11.1",
5555
"@webpack-cli/serve": "^0.2.0",
56-
"chalk": "^4.1.1",
57-
"find-up": "^5.0.0",
5856
"lerna": "^4.0.0",
59-
"minimist": "^1.2.5",
6057
"npm-cli-adduser": "^1.1.4",
61-
"ora": "^5.4.0",
62-
"pacote": "^11.3.5",
63-
"pkg-up": "^3.1.0",
64-
"prompts": "^2.4.1",
65-
"ps-list": "^7.2.0",
66-
"semver": "^7.3.5",
6758
"wait-on": "^5.3.0"
6859
},
6960
"engines": {
@@ -76,6 +67,7 @@
7667
},
7768
"workspaces": [
7869
"packages/*",
79-
"configs/*"
70+
"configs/*",
71+
"scripts"
8072
]
8173
}

scripts/.depcheckrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignores:
2+
- "@mongodb-js/prettier-config-compass"

scripts/.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc-output
2+
dist

scripts/.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['@mongodb-js/eslint-config-compass'],
4+
};

scripts/.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.nyc-output
2+
dist

scripts/.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@mongodb-js/prettier-config-compass"

scripts/bump-private-dependencies.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function main() {
5252
for (const depType of [
5353
'dependencies',
5454
'devDependencies',
55-
'peerDependencies'
55+
'peerDependencies',
5656
]) {
5757
if (!packageJson[depType]) {
5858
continue;

scripts/changed.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function runCommandForPackages(command, packages) {
1919
{
2020
cwd: process.cwd(),
2121
stdio: 'inherit',
22-
timeout: 1000 * 60 * 20
22+
timeout: 1000 * 60 * 20,
2323
}
2424
);
2525

@@ -46,15 +46,15 @@ async function runCommandForPackages(command, packages) {
4646
message: `Running ${command} for the package ${pkg.name} failed`,
4747
choices: [
4848
{ title: 'Re-run', value: 'rerun' },
49-
{ title: 'Skip', value: 'skip' }
49+
{ title: 'Skip', value: 'skip' },
5050
],
51-
initial: 0
52-
}
51+
initial: 0,
52+
},
5353
],
5454
{
5555
onCancel() {
5656
canceled = true;
57-
}
57+
},
5858
}
5959
);
6060

@@ -80,6 +80,7 @@ async function runCommandForPackages(command, packages) {
8080
async function runUntilDone(command, packages) {
8181
packages = [...packages];
8282

83+
// eslint-disable-next-line no-constant-condition
8384
while (true) {
8485
const { passed, failed } = await runCommandForPackages(command, packages);
8586

@@ -107,7 +108,7 @@ async function runUntilDone(command, packages) {
107108
type: 'confirm',
108109
name: 'shouldRerun',
109110
message: 'Do you want to rerun failed scripts?',
110-
initial: true
111+
initial: true,
111112
});
112113

113114
if (shouldRerun === false) {
@@ -161,7 +162,7 @@ async function main() {
161162
'run',
162163
'--stream',
163164
command,
164-
...changedPackages.map((pkg) => ['--scope', pkg.name]).flat()
165+
...changedPackages.map((pkg) => ['--scope', pkg.name]).flat(),
165166
],
166167
{ cwd: process.cwd(), stdio: 'inherit' }
167168
);

scripts/check-logids.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ async function main() {
77

88
for (const line of stdout.split('\n').filter(Boolean)) {
99
// git grep -H gives us `${filename}:${source}`
10-
const { filename, source } = line.match(/^(?<filename>[^:]+):(?<source>.+)$/).groups;
11-
if (filename.match(/\.(spec|test)\.(js|jsx|ts|tsx)$/))
12-
continue;
10+
const { filename, source } = line.match(
11+
/^(?<filename>[^:]+):(?<source>.+)$/
12+
).groups;
13+
if (filename.match(/\.(spec|test)\.(js|jsx|ts|tsx)$/)) continue;
1314

1415
if (source.match(/mongoLogId\([^)]*$/)) {
15-
process.exitCode = 1;
16-
console.error(`Unmatched mongoLogId() parentheses:`);
17-
console.error(`${filename}: ${source}`);
16+
process.exitCode = 1;
17+
console.error(`Unmatched mongoLogId() parentheses:`);
18+
console.error(`${filename}: ${source}`);
1819
}
1920

2021
// match all mongoLogId() calls, possibly containing _ as a numeric separator
2122
const logIdMatches = source.matchAll(/mongoLogId\((?<rawId>[^)]+)\)/g);
22-
for (const { groups: { rawId } } of logIdMatches) {
23+
for (const {
24+
groups: { rawId },
25+
} of logIdMatches) {
2326
if (!rawId.match(/^ *[0-9_]+ *$/)) {
2427
process.exitCode = 1;
2528
console.error(`Log id ${rawId} does not match the expected format:`);

scripts/create-workspace.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const prompts = require('prompts');
44
const pacote = require('pacote');
55
const {
66
collectWorkspacesDependencies,
7-
collectWorkspacesMeta
7+
collectWorkspacesMeta,
88
} = require('./workspace-dependencies');
99
const { getHighestRange } = require('./semver-helpers');
1010
const { runInDir } = require('./run-in-dir');
@@ -57,7 +57,7 @@ async function main(argv) {
5757
isPublic = true,
5858
isReact = true,
5959
dependants = [],
60-
depType
60+
depType,
6161
} = await prompts(
6262
[
6363
{
@@ -75,18 +75,18 @@ async function main(argv) {
7575
}
7676

7777
return true;
78-
}
78+
},
7979
},
8080
{
8181
type: 'text',
8282
name: 'description',
83-
message: 'Provide a one-line description of the workspace'
83+
message: 'Provide a one-line description of the workspace',
8484
},
8585
{
8686
type: 'confirm',
8787
name: 'isPlugin',
8888
message: 'Are you creating a new Compass plugin?',
89-
initial: true
89+
initial: true,
9090
},
9191
{
9292
type(_, { name, description, isPlugin }) {
@@ -100,7 +100,7 @@ async function main(argv) {
100100
name: 'isConfig',
101101
message: 'Is it a shared configuration package?',
102102
hint: '(answering yes will create the package in the ./configs/<package-name> directory)',
103-
initial: true
103+
initial: true,
104104
},
105105
{
106106
type(_, { isPlugin }) {
@@ -112,7 +112,7 @@ async function main(argv) {
112112
},
113113
name: 'isPublic',
114114
message: 'Is it a public package?',
115-
initial: true
115+
initial: true,
116116
},
117117
{
118118
type(_, { isPlugin }) {
@@ -124,7 +124,7 @@ async function main(argv) {
124124
},
125125
name: 'isReact',
126126
message: 'Will the package use React?',
127-
initial: true
127+
initial: true,
128128
},
129129
{
130130
type(_, { isPlugin }) {
@@ -147,7 +147,7 @@ async function main(argv) {
147147
· Type text to filter choices
148148
· Enter to complete the answer
149149
`,
150-
initial: []
150+
initial: [],
151151
},
152152
{
153153
type(prev) {
@@ -157,14 +157,14 @@ async function main(argv) {
157157
message: 'What type of dependency is it?',
158158
choices: [
159159
{ title: 'Production', value: 'dependencies' },
160-
{ title: 'Development', value: 'devDependencies' }
161-
]
162-
}
160+
{ title: 'Development', value: 'devDependencies' },
161+
],
162+
},
163163
],
164164
{
165165
onCancel() {
166166
canceled = true;
167-
}
167+
},
168168
}
169169
);
170170

@@ -177,7 +177,7 @@ async function main(argv) {
177177
dependants = [
178178
Array.from(workspacesMeta.values()).find(
179179
(ws) => ws.name === 'mongodb-compass'
180-
).location
180+
).location,
181181
];
182182
depType = 'devDependencies';
183183
}
@@ -189,18 +189,18 @@ async function main(argv) {
189189
...(description && { description }),
190190
author: {
191191
name: 'MongoDB Inc',
192-
192+
193193
},
194194
...(isPublic ? { publishConfig: { access: 'public' } } : { private: true }),
195195
bugs: {
196196
url: 'https://jira.mongodb.org/projects/COMPASS/issues',
197-
197+
198198
},
199199
homepage: 'https://github.com/mongodb-js/compass',
200200
version: '0.1.0',
201201
repository: {
202202
type: 'git',
203-
url: 'https://github.com/mongodb-js/compass.git'
203+
url: 'https://github.com/mongodb-js/compass.git',
204204
},
205205
files: ['dist'],
206206
license: 'SSPL',
@@ -209,15 +209,15 @@ async function main(argv) {
209209
webpack: './src/index.ts',
210210
require: './dist/index.js',
211211
...(!isPlugin && {
212-
import: './dist/.esm-wrapper.mjs'
213-
})
212+
import: './dist/.esm-wrapper.mjs',
213+
}),
214214
},
215215
types: './dist/index.d.ts',
216216
scripts: {
217217
// Plugins are bundled by webpack from source and tested with ts-node
218218
// runtime processor, no need to bootstrap them
219219
...(!isPlugin && {
220-
bootstrap: 'npm run compile'
220+
bootstrap: 'npm run compile',
221221
}),
222222
prepublishOnly: 'npm run compile',
223223
// For normal packages we are just compiling code with typescript, for
@@ -230,7 +230,7 @@ async function main(argv) {
230230
prewebpack: 'rimraf ./lib',
231231
webpack: 'webpack-compass',
232232
start: 'npm run webpack serve -- --mode development',
233-
analyze: 'npm run webpack -- --mode production --analyze'
233+
analyze: 'npm run webpack -- --mode production --analyze',
234234
}),
235235
eslint: 'eslint',
236236
prettier: 'prettier',
@@ -245,7 +245,7 @@ async function main(argv) {
245245
'test-ci': isPlugin
246246
? 'npm run test-electron && npm run test-cov'
247247
: 'npm run test-cov',
248-
reformat: 'npm run prettier -- --write .'
248+
reformat: 'npm run prettier -- --write .',
249249
},
250250
...(isReact && { peerDependencies: { react: '*', 'react-dom': '*' } }),
251251
...(isReact && { dependencies: { react: '*', 'react-dom': '*' } }),
@@ -269,19 +269,19 @@ async function main(argv) {
269269
'@testing-library/user-event': '*',
270270
'@types/chai-dom': '*',
271271
'@types/react': '*',
272-
'@types/react-dom': '*'
272+
'@types/react-dom': '*',
273273
}),
274274
...(!isPlugin && {
275275
typescript: '*',
276-
'gen-esm-wrapper': '*'
276+
'gen-esm-wrapper': '*',
277277
}),
278278
...(isPlugin && {
279279
'@mongodb-js/webpack-config-compass': '*',
280280
'hadron-app-registry': '*',
281281
rimraf: '*',
282-
'xvfb-maybe': '*'
283-
})
284-
}
282+
'xvfb-maybe': '*',
283+
}),
284+
},
285285
};
286286

287287
await applyBestVersionMatch(pkgJson, workspacesMeta);
@@ -304,7 +304,7 @@ async function main(argv) {
304304
'@mongodb-js/tsconfig-compass',
305305
'@types/chai',
306306
'@types/sinon-chai',
307-
'sinon'
307+
'sinon',
308308
]
309309
.concat(
310310
isReact ? ['@types/chai-dom', '@types/react', '@types/react-dom'] : []
@@ -328,10 +328,10 @@ async function main(argv) {
328328
isReact ? 'react' : 'common'
329329
}.json`,
330330
compilerOptions: {
331-
outDir: 'dist'
331+
outDir: 'dist',
332332
},
333333
include: ['src/**/*'],
334-
exclude: ['./src/**/*.spec.*']
334+
exclude: ['./src/**/*.spec.*'],
335335
},
336336
null,
337337
2
@@ -342,7 +342,7 @@ async function main(argv) {
342342
{
343343
extends: './tsconfig.json',
344344
include: ['**/*'],
345-
exclude: ['node_modules', 'dist']
345+
exclude: ['node_modules', 'dist'],
346346
},
347347
null,
348348
2

0 commit comments

Comments
 (0)