Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/check-new-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0

- name: Detect if a new package was added
id: detect
Expand All @@ -43,21 +45,23 @@ jobs:
const packageNames = '${{ steps.detect.outputs.package_names }}';
const packageList = packageNames.split(',').map(name => `\`${name}\``).join(', ');

const commentBody = "### New `@theia` Package(s) Detected
const commentBody = `
### New \`@theia\` Package(s) Detected

This PR adds the following new package(s): ${packageList}

Please ensure the following checklist items are completed before merging:

- [ ] `package.json` contains all required fields (name, version, description, license, etc.) and scripts
- [ ] `README.md` was added (please align with the existing README structure, e.g. [README.md](https://github.com/eclipse-theia/theia/blob/master/packages/editor/README.md))
- [ ] Config files (`tsconfig.json`, `.eslintrc.js`) were added and align with the existing packages
- [ ] \`package.json\` contains all required fields (name, version, description, license, etc.) and scripts
- [ ] \`README.md\` was added (please align with the existing README structure, e.g. [README.md](https://github.com/eclipse-theia/theia/blob/master/packages/editor/README.md))
- [ ] Config files (\`tsconfig.json\`, \`.eslintrc.js\`) were added and align with the existing packages
- [ ] Folder structure follows Theia conventions (see [Code Organization](https://github.com/eclipse-theia/theia/blob/master/doc/code-organization.md))
- [ ] Package is added to the example applications (i.e. `browser`, `browser-only`, `electron`)
- [ ] Package is added to the example applications (i.e. \`browser\`, \`browser-only\`, \`electron\`)
- [ ] New packages must be published manually by a Theia committer initially (see also [Release Process - Newly added Theia packages](https://github.com/eclipse-theia/theia/blob/master/doc/Publishing.md#212-newly-added-theia-packages---publish-initially-to-npm)).
If you are not a committer or do not have enough time, please open a follow-up ticket with the label `toDoWithRelease` to inform the release team about the new package.
If you are not a committer or do not have enough time, please open a follow-up ticket with the label \`toDoWithRelease\` to inform the release team about the new package (see for example: <https://github.com/eclipse-theia/theia/issues/16651>).
- [ ] If the package should also be part of the Theia IDE, please [open a ticket for the Theia IDE](https://github.com/eclipse-theia/theia-ide/issues/new?template=feature_request.md)
and assign the `toDoWithRelease` (see for example: <https://github.com/eclipse-theia/theia-ide/issues/615>)"
and assign the \`toDoWithRelease\` (see for example: <https://github.com/eclipse-theia/theia-ide/issues/615>)
`;

const issue_number = context.issue.number;
const owner = context.repo.owner;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"postinstall": "theia-patch && npm run -s compute-references && lerna run afterInstall",
"publish:latest": "lerna publish --exact --yes",
"publish:patch": "lerna publish --exact --yes --dist-tag patch",
"publish:next": "lerna publish --canary preminor --exact --yes --preid next --dist-tag next && npm run -s publish:check",
"publish:next": "lerna publish --canary preminor --exact --yes --preid next --dist-tag next && npm run -s publish:check next",
"publish:check": "node scripts/check-publish.js",
"rebuild:clean": "rimraf .browser_modules",
"rebuild:browser": "cd examples/browser && npm run rebuild",
Expand Down
52 changes: 38 additions & 14 deletions scripts/check-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,54 @@ const chalk = require('chalk').default;
const cp = require('child_process');
const fs = require('fs');

checkPublish().catch(error => {
const distTag = process.argv[2];

checkPublish(distTag).catch(error => {
console.error(error);
process.exitCode = 1;
});

async function checkPublish() {
async function checkPublish(distTag) {
const workspaces = JSON.parse(cp.execSync('npx lerna ls --json --loglevel=silent').toString());
await Promise.all(workspaces.map(async workspace => {
const packagePath = path.resolve(workspace.location, 'package.json');
const pck = JSON.parse(await fs.promises.readFile(packagePath, 'utf8'));
if (!pck.private) {
const pckName = `${pck.name}@${pck.version}`;
const npmViewOutput = await new Promise(
resolve => cp.exec(`npm view ${pckName} version --json`,
(error, stdout, stderr) => {
if (error) {
console.error(error);
resolve('');
} else {
resolve(stdout.trim());
let pckName;
let npmViewOutput;

if (distTag === 'next') {
pckName = `${pck.name}@next`;
npmViewOutput = await new Promise(
resolve => cp.exec(`npm view ${pckName} version`,
(error, stdout, stderr) => {
if (error) {
console.error(error);
resolve('');
} else {
// update pckName print to the actual next version below
pckName = `${pck.name}@${stdout.trim()}`;
resolve(pckName);
}
}
)
);
} else {
pckName = `${pck.name}@${pck.version}`
npmViewOutput = await new Promise(
resolve => cp.exec(`npm view ${pckName} version`,
(error, stdout, stderr) => {
if (error) {
console.error(error);
resolve('');
} else {
resolve(stdout.trim());
}
}
}
)
);
)
);
}

if (npmViewOutput) {
console.info(`${pckName}: published`);
} else {
Expand Down
Loading