Skip to content

Commit

Permalink
releases work, disable pre-release for now
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Apr 11, 2022
1 parent 04b8c80 commit ecd444b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"prepublishOnly": "./scripts/prepublish.sh",
"pretty": "node scripts/pretty.js",
"pretty-check": "node scripts/pretty.js --check",
"release": "yarn build && yarn build-bundles && yarn changeset publish && wsrun release",
"release": "yarn build && yarn build-bundles && yarn changeset publish",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn build-bundles && yarn changeset publish --tag canary) || echo Skipping Canary...",
"repo:lint": "manypkg check",
"repo:fix": "manypkg fix",
Expand Down
10 changes: 5 additions & 5 deletions packages/graphql-language-service-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ The graphql-config features we support are:
module.exports = {
extensions: {
// add customDirectives *legacy*. you can now provide multiple schema pointers to config.schema/project.schema, including inline strings
customDirectives: ["@myExampleDirective"],
customDirectives: ['@myExampleDirective'],
// a function that returns rules array with parameter `ValidationContext` from `graphql/validation`
customValidationRules: require('./config/customValidationRules'),
languageService: {
// should the language service read schema for lookups from a cached file based on graphql config output?
cacheSchemaFileForLookup: true
cacheSchemaFileForLookup: true,
// NOTE: this will disable all definition lookup for local SDL files
}
}
}
},
},
};
```

we also load `require('dotenv').config()`, so you can use process.env variables from local `.env` files!
Expand Down
33 changes: 17 additions & 16 deletions packages/monaco-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,19 @@ window.MonacoEnvironment = {

// the language service will be instantiated once the schema is available
const MonacoGraphQLAPI = initializeMode({
schemas: [{
// anything that monaco.URI.from() is compatible with
uri: 'https://myschema.com',
// match the monaco file uris for this schema.
// accepts specific filenames and anything `picomatch` supports.
fileMatch: ["**/*.graphql"],
schema: myGraphqlSchema as GraphQLSchema
}],
})

schemas: [
{
// anything that monaco.URI.from() is compatible with
uri: 'https://myschema.com',
// match the monaco file uris for this schema.
// accepts specific filenames and anything `picomatch` supports.
fileMatch: ['**/*.graphql'],
schema: myGraphqlSchema as GraphQLSchema,
},
],
});

const operationModel = monaco.editor.createModel(
const operationModel = monaco.editor.createModel(
'query {}',
'graphql',
'/operation.graphql',
Expand Down Expand Up @@ -201,12 +202,12 @@ MonacoGraphQLAPI.setDiagnosticSettings({
// and compute the json schema using the GraphQLWorker.
// This is in the main process is applied to the global monaco json settings
// for validation, completion and more using monaco-json's built-in JSON Schema support.
[operationModel.uri.toString()]: [variablesModel.uri.toString()]
[operationModel.uri.toString()]: [variablesModel.uri.toString()],
},
jsonDiagnosticSettings: {
allowComments: true, // allow json, parse with a jsonc parser to make requests
}
})
},
});
// TODO: document manual alternative approach
```

Expand Down Expand Up @@ -266,13 +267,13 @@ or you can load the language features only when you have your schema
```ts
import { initializeMode } from 'monaco-graphql/esm/initializeMode';

const schemas = [
const schemas = [
{
schema: GraphQLSchema,
fileMatch: ['operations/*.graphql'],
uri: 'myschema.graphql',
},
]
];
const api = intializeMode({ schemas });

// add another schema. this will cause language workers and features to reset
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-graphql",
"version": "0.4.3",
"version": "0.4.1",
"preview": true,
"private": true,
"license": "MIT",
Expand Down Expand Up @@ -220,7 +220,7 @@
"env:source": "export $(cat .envrc | xargs)",
"vsce:publish": "vsce publish --yarn --pat \"$PAT_TOKEN\"",
"open-vsx:publish": "ovsx publish --pat \"$OPEN_VSX_ACCESS_TOKEN\"",
"release": "npm run vsce:publish && npm run open-vsx:publish"
"postpublish": "npm run vsce:publish && npm run open-vsx:publish"
},
"devDependencies": {
"@types/capitalize": "2.0.0",
Expand Down
49 changes: 35 additions & 14 deletions scripts/canary-release.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */
const semver = require('semver');
const { execa } = import('execa');
const cp = require('child_process');
const { basename } = require('path');

Expand All @@ -19,22 +20,29 @@ function getNewVersion(version, type) {
return semver.inc(version, `pre${type}`, true, 'canary-' + gitHash);
}

function getRelevantChangesets(baseBranch) {
const comparePoint = cp
.spawnSync('git', ['merge-base', `origin/${baseBranch}`, 'HEAD'])
.stdout.toString()
.trim();
const listModifiedFiles = cp
.spawnSync('git', ['diff', '--name-only', comparePoint])
.stdout.toString()
.trim()
.split('\n');
const execOpts = { stderr: 'inherit', stdout: 'inherit' };

const items = listModifiedFiles
.filter(f => f.startsWith('.changeset'))
.map(f => basename(f, '.md'));
const git = async (...commands) => execa('git', commands, execOpts);

return items;
async function preReleaseVSCode(version) {
try {
await execa(
'yarn',
['workspace', `vscode-graphql`, 'run', 'release', '--pre'],
execOpts,
);
} catch (err) {
console.error('vscode-graphql pre-release failed on publish:', err);
process.exit(1);
}
try {
await git('add', `packages/vscode-graphql/package.json`);
await git('commit', `-m`, `pre-release \`vscode-graphql@${version}\``);
await git('push');
} catch (err) {
console.error('vscode-graphql pre-release failed on git command:', err);
process.exit(1);
}
}

async function updateVersions() {
Expand All @@ -45,6 +53,9 @@ async function updateVersions() {
const changesets = (await readChangesets(cwd)).filter(change =>
modifiedChangesets.includes(change.id),
);
const isMain = process.env.GITHUB_REF_NAME?.includes('main');

let vscodeRelease = false;

if (changesets.length === 0) {
console.warn(
Expand All @@ -67,6 +78,13 @@ async function updateVersions() {
process.exit(1);
} else {
for (const release of releasePlan.releases) {
if (
release.name.includes('vscode-graphql') &&
release.changesets?.type !== 'none'
) {
// vsce pre-release only accept x.y.z versions
release.newVersion = vscodeRelease = semver.patch(release.oldVersion);
}
if (release.type !== 'none') {
release.newVersion = getNewVersion(release.oldVersion, release.type);
}
Expand All @@ -82,6 +100,9 @@ async function updateVersions() {
false,
true,
);
// if(vscodeRelease) {
// await preReleaseVSCode(vscodeRelease)
// }
}
}
}
Expand Down

0 comments on commit ecd444b

Please sign in to comment.