Skip to content

Commit

Permalink
rfc(@blocks-*): export modules
Browse files Browse the repository at this point in the history
  • Loading branch information
wootsbot committed Oct 12, 2023
1 parent 45f05fc commit 61d32ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 7 additions & 3 deletions packages/@blocks-unstyled/scripts/modulesGeneration.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const fs = require("fs");
const fs = require("fs-extra");
const path = require("path");

const rootSourceDir = path.join(__dirname, "..");
const rootDirOutput = path.join(__dirname, "..", "build-temp");
const rootDirOutputPath = path.join(__dirname, "..", "build-temp");
const indexFilePath = path.join(rootSourceDir, "src", "index.ts");

if (!fs.existsSync(rootDirOutputPath)) {
fs.ensureDirSync(path.join(rootDirOutputPath));
}

const content = fs.readFileSync(indexFilePath, "utf8");

const matches = content.match(/export \* from '\.\/(\w+)'/g);
Expand All @@ -27,7 +31,7 @@ function generatePackageJson(componentName) {
}

componentNames.forEach((name) => {
const outputPath = path.join(rootDirOutput, name);
const outputPath = path.join(rootDirOutputPath, name);

if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath);
Expand Down
26 changes: 16 additions & 10 deletions packages/@blocks-unstyled/scripts/preparePublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const path = require("path");
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
console.log("Preparing publish... codea");

const rootDirOutput = path.join(__dirname, "..", "build-temp");
const rootDirOutputPath = path.join(__dirname, "..", "build-temp");

if (!fs.existsSync(rootDirOutput)) {
fs.ensureDirSync(path.join(rootDirOutput));
if (!fs.existsSync(rootDirOutputPath)) {
fs.ensureDirSync(path.join(rootDirOutputPath));
}

const sharedPkg = fs.readFileSync("./package.json", "utf-8");
Expand All @@ -33,20 +33,26 @@ delete sharedPkgFormat.bundlesize;
delete sharedPkgFormat["react-native-builder-bob"];

fs.writeFileSync(
path.join("./build-temp", "package.json"),
path.join(rootDirOutputPath, "package.json"),
JSON.stringify(sharedPkgFormat, null, 2)
);

fs.copySync(
path.join(__dirname, "../README.md"),
path.join(rootDirOutput, "README.md")
path.join(rootDirOutputPath, "README.md")
);

fs.copySync(path.join(__dirname, "../src"), path.join(rootDirOutput, "src"));
fs.copySync(
path.join(__dirname, "../src"),
path.join(rootDirOutputPath, "src")
);

fs.copySync(path.join(__dirname, "../build"), path.join(rootDirOutputPath));

if (!fs.existsSync(rootDirOutputPath)) {
fs.ensureDirSync(path.join(rootDirOutputPath));
}

fs.copySync(path.join(__dirname, "../build"), path.join(rootDirOutput));
fs.moveSync(path.join(rootDirOutputPath), path.join(__dirname, ".."));

fs.moveSync(path.join(rootDirOutput), path.join(__dirname, ".."), {
overwrite: true,
});
fs.removeSync(path.join(__dirname, "../build"));

0 comments on commit 61d32ee

Please sign in to comment.