Skip to content

Commit

Permalink
chore: add script to import test connections (#2612)
Browse files Browse the repository at this point in the history
* chore: add script to import test connections

* move scripts to package + fix eslint

* use uuidv5 and prompt

* regen package-lock
  • Loading branch information
mcasimir authored Dec 14, 2021
1 parent 1b22bad commit aa11bff
Show file tree
Hide file tree
Showing 24 changed files with 785 additions and 435 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"packages": ["packages/*", "configs/*"],
"packages": ["packages/*", "configs/*", "scripts"],
"version": "independent"
}
290 changes: 109 additions & 181 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,8 @@
"devDependencies": {
"@testing-library/dom": "^8.11.1",
"@webpack-cli/serve": "^0.2.0",
"chalk": "^4.1.1",
"find-up": "^5.0.0",
"lerna": "^4.0.0",
"minimist": "^1.2.5",
"npm-cli-adduser": "^1.1.4",
"ora": "^5.4.0",
"pacote": "^11.3.5",
"pkg-up": "^3.1.0",
"prompts": "^2.4.1",
"ps-list": "^7.2.0",
"semver": "^7.3.5",
"wait-on": "^5.3.0"
},
"engines": {
Expand All @@ -76,6 +67,7 @@
},
"workspaces": [
"packages/*",
"configs/*"
"configs/*",
"scripts"
]
}
2 changes: 2 additions & 0 deletions scripts/.depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignores:
- "@mongodb-js/prettier-config-compass"
2 changes: 2 additions & 0 deletions scripts/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc-output
dist
4 changes: 4 additions & 0 deletions scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['@mongodb-js/eslint-config-compass'],
};
2 changes: 2 additions & 0 deletions scripts/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc-output
dist
1 change: 1 addition & 0 deletions scripts/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@mongodb-js/prettier-config-compass"
2 changes: 1 addition & 1 deletion scripts/bump-private-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function main() {
for (const depType of [
'dependencies',
'devDependencies',
'peerDependencies'
'peerDependencies',
]) {
if (!packageJson[depType]) {
continue;
Expand Down
15 changes: 8 additions & 7 deletions scripts/changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function runCommandForPackages(command, packages) {
{
cwd: process.cwd(),
stdio: 'inherit',
timeout: 1000 * 60 * 20
timeout: 1000 * 60 * 20,
}
);

Expand All @@ -46,15 +46,15 @@ async function runCommandForPackages(command, packages) {
message: `Running ${command} for the package ${pkg.name} failed`,
choices: [
{ title: 'Re-run', value: 'rerun' },
{ title: 'Skip', value: 'skip' }
{ title: 'Skip', value: 'skip' },
],
initial: 0
}
initial: 0,
},
],
{
onCancel() {
canceled = true;
}
},
}
);

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

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

Expand Down Expand Up @@ -107,7 +108,7 @@ async function runUntilDone(command, packages) {
type: 'confirm',
name: 'shouldRerun',
message: 'Do you want to rerun failed scripts?',
initial: true
initial: true,
});

if (shouldRerun === false) {
Expand Down Expand Up @@ -161,7 +162,7 @@ async function main() {
'run',
'--stream',
command,
...changedPackages.map((pkg) => ['--scope', pkg.name]).flat()
...changedPackages.map((pkg) => ['--scope', pkg.name]).flat(),
],
{ cwd: process.cwd(), stdio: 'inherit' }
);
Expand Down
17 changes: 10 additions & 7 deletions scripts/check-logids.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ async function main() {

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

if (source.match(/mongoLogId\([^)]*$/)) {
process.exitCode = 1;
console.error(`Unmatched mongoLogId() parentheses:`);
console.error(`${filename}: ${source}`);
process.exitCode = 1;
console.error(`Unmatched mongoLogId() parentheses:`);
console.error(`${filename}: ${source}`);
}

// match all mongoLogId() calls, possibly containing _ as a numeric separator
const logIdMatches = source.matchAll(/mongoLogId\((?<rawId>[^)]+)\)/g);
for (const { groups: { rawId } } of logIdMatches) {
for (const {
groups: { rawId },
} of logIdMatches) {
if (!rawId.match(/^ *[0-9_]+ *$/)) {
process.exitCode = 1;
console.error(`Log id ${rawId} does not match the expected format:`);
Expand Down
62 changes: 31 additions & 31 deletions scripts/create-workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const prompts = require('prompts');
const pacote = require('pacote');
const {
collectWorkspacesDependencies,
collectWorkspacesMeta
collectWorkspacesMeta,
} = require('./workspace-dependencies');
const { getHighestRange } = require('./semver-helpers');
const { runInDir } = require('./run-in-dir');
Expand Down Expand Up @@ -57,7 +57,7 @@ async function main(argv) {
isPublic = true,
isReact = true,
dependants = [],
depType
depType,
} = await prompts(
[
{
Expand All @@ -75,18 +75,18 @@ async function main(argv) {
}

return true;
}
},
},
{
type: 'text',
name: 'description',
message: 'Provide a one-line description of the workspace'
message: 'Provide a one-line description of the workspace',
},
{
type: 'confirm',
name: 'isPlugin',
message: 'Are you creating a new Compass plugin?',
initial: true
initial: true,
},
{
type(_, { name, description, isPlugin }) {
Expand All @@ -100,7 +100,7 @@ async function main(argv) {
name: 'isConfig',
message: 'Is it a shared configuration package?',
hint: '(answering yes will create the package in the ./configs/<package-name> directory)',
initial: true
initial: true,
},
{
type(_, { isPlugin }) {
Expand All @@ -112,7 +112,7 @@ async function main(argv) {
},
name: 'isPublic',
message: 'Is it a public package?',
initial: true
initial: true,
},
{
type(_, { isPlugin }) {
Expand All @@ -124,7 +124,7 @@ async function main(argv) {
},
name: 'isReact',
message: 'Will the package use React?',
initial: true
initial: true,
},
{
type(_, { isPlugin }) {
Expand All @@ -147,7 +147,7 @@ async function main(argv) {
· Type text to filter choices
· Enter to complete the answer
`,
initial: []
initial: [],
},
{
type(prev) {
Expand All @@ -157,14 +157,14 @@ async function main(argv) {
message: 'What type of dependency is it?',
choices: [
{ title: 'Production', value: 'dependencies' },
{ title: 'Development', value: 'devDependencies' }
]
}
{ title: 'Development', value: 'devDependencies' },
],
},
],
{
onCancel() {
canceled = true;
}
},
}
);

Expand All @@ -177,7 +177,7 @@ async function main(argv) {
dependants = [
Array.from(workspacesMeta.values()).find(
(ws) => ws.name === 'mongodb-compass'
).location
).location,
];
depType = 'devDependencies';
}
Expand All @@ -189,18 +189,18 @@ async function main(argv) {
...(description && { description }),
author: {
name: 'MongoDB Inc',
email: '[email protected]'
email: '[email protected]',
},
...(isPublic ? { publishConfig: { access: 'public' } } : { private: true }),
bugs: {
url: 'https://jira.mongodb.org/projects/COMPASS/issues',
email: '[email protected]'
email: '[email protected]',
},
homepage: 'https://github.com/mongodb-js/compass',
version: '0.1.0',
repository: {
type: 'git',
url: 'https://github.com/mongodb-js/compass.git'
url: 'https://github.com/mongodb-js/compass.git',
},
files: ['dist'],
license: 'SSPL',
Expand All @@ -209,15 +209,15 @@ async function main(argv) {
webpack: './src/index.ts',
require: './dist/index.js',
...(!isPlugin && {
import: './dist/.esm-wrapper.mjs'
})
import: './dist/.esm-wrapper.mjs',
}),
},
types: './dist/index.d.ts',
scripts: {
// Plugins are bundled by webpack from source and tested with ts-node
// runtime processor, no need to bootstrap them
...(!isPlugin && {
bootstrap: 'npm run compile'
bootstrap: 'npm run compile',
}),
prepublishOnly: 'npm run compile',
// For normal packages we are just compiling code with typescript, for
Expand All @@ -230,7 +230,7 @@ async function main(argv) {
prewebpack: 'rimraf ./lib',
webpack: 'webpack-compass',
start: 'npm run webpack serve -- --mode development',
analyze: 'npm run webpack -- --mode production --analyze'
analyze: 'npm run webpack -- --mode production --analyze',
}),
eslint: 'eslint',
prettier: 'prettier',
Expand All @@ -245,7 +245,7 @@ async function main(argv) {
'test-ci': isPlugin
? 'npm run test-electron && npm run test-cov'
: 'npm run test-cov',
reformat: 'npm run prettier -- --write .'
reformat: 'npm run prettier -- --write .',
},
...(isReact && { peerDependencies: { react: '*', 'react-dom': '*' } }),
...(isReact && { dependencies: { react: '*', 'react-dom': '*' } }),
Expand All @@ -269,19 +269,19 @@ async function main(argv) {
'@testing-library/user-event': '*',
'@types/chai-dom': '*',
'@types/react': '*',
'@types/react-dom': '*'
'@types/react-dom': '*',
}),
...(!isPlugin && {
typescript: '*',
'gen-esm-wrapper': '*'
'gen-esm-wrapper': '*',
}),
...(isPlugin && {
'@mongodb-js/webpack-config-compass': '*',
'hadron-app-registry': '*',
rimraf: '*',
'xvfb-maybe': '*'
})
}
'xvfb-maybe': '*',
}),
},
};

await applyBestVersionMatch(pkgJson, workspacesMeta);
Expand All @@ -304,7 +304,7 @@ async function main(argv) {
'@mongodb-js/tsconfig-compass',
'@types/chai',
'@types/sinon-chai',
'sinon'
'sinon',
]
.concat(
isReact ? ['@types/chai-dom', '@types/react', '@types/react-dom'] : []
Expand All @@ -328,10 +328,10 @@ async function main(argv) {
isReact ? 'react' : 'common'
}.json`,
compilerOptions: {
outDir: 'dist'
outDir: 'dist',
},
include: ['src/**/*'],
exclude: ['./src/**/*.spec.*']
exclude: ['./src/**/*.spec.*'],
},
null,
2
Expand All @@ -342,7 +342,7 @@ async function main(argv) {
{
extends: './tsconfig.json',
include: ['**/*'],
exclude: ['node_modules', 'dist']
exclude: ['node_modules', 'dist'],
},
null,
2
Expand Down
Loading

0 comments on commit aa11bff

Please sign in to comment.