Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗 Automatically write react.js files for bento components when publishing #34586

Merged
merged 4 commits into from
May 27, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
pr comments
  • Loading branch information
estherkim committed May 27, 2021
commit 108cf8a025d7f275d890a495163b5412b93a9be6
21 changes: 19 additions & 2 deletions build-system/npm-publish/write-package-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ const {log} = require('../common/logging');
const {stat, writeFile} = require('fs/promises');
const {valid} = require('semver');

async function skip(extensionVersion) {
/**
* Determines whether to skip
* @param {string} extensionVersion
* @returns {Promise<boolean>}
*/
async function shouldSkip(extensionVersion) {
try {
await stat(`extensions/${extension}/${extensionVersion}`);
return false;
Expand All @@ -34,6 +39,10 @@ async function skip(extensionVersion) {
}
}

/**
* Write package.json
* @param {string} extensionVersion
*/
async function writePackageJson(extensionVersion) {
const extensionVersionArr = extensionVersion.split('.', 2);
const major = extensionVersionArr[0];
Expand Down Expand Up @@ -107,6 +116,10 @@ async function writePackageJson(extensionVersion) {
}
}

/**
* Write react.js
* @param {string} extensionVersion
*/
async function writeReactJs(extensionVersion) {
const content = "module.exports = require('./dist/component-react');";
try {
Expand All @@ -121,9 +134,13 @@ async function writeReactJs(extensionVersion) {
return;
}
}

/**
* Main
*/
async function main() {
for (const version of ['1.0', '2.0']) {
if (await skip(version)) {
if (await shouldSkip(version)) {
continue;
}
writePackageJson(version);
Expand Down