Skip to content

Commit

Permalink
🎨 [#724] Convert prepare-package.js to module and drop dependency on …
Browse files Browse the repository at this point in the history
…config/paths.js
  • Loading branch information
sergei-maertens committed Jan 6, 2025
1 parent 7429dcd commit 3847a88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions bin/prepare-package.js → bin/prepare-package.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
import fs from 'fs';
import path from 'path';

const paths = require('../config/paths');
const APP_DIRECTORY = fs.realpathSync(process.cwd());
const PACKAGE_JSON_PATH = path.resolve(APP_DIRECTORY, 'package.json');

const packageJson = JSON.parse(fs.readFileSync(paths.appPackageJson, 'utf-8'));
const packageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON_PATH, 'utf-8'));

// make package.json modifications to be able to publish the package. Workspaces require
// private=true, but to publish it, it must be private=false. While publishing the
// package, we do not use workspaces.
packageJson.private = false;

const stringified = JSON.stringify(packageJson, null, 2) + '\n';
fs.writeFileSync(paths.appPackageJson, stringified);
fs.writeFileSync(PACKAGE_JSON_PATH, stringified);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"build": "BUILD_TARGET=umd vite build && BUILD_TARGET=esm vite build",
"test": "TZ=Europe/Amsterdam vitest",
"test:storybook": "test-storybook --coverage",
"prepare-package": "node bin/prepare-package.js",
"prepare-package": "node bin/prepare-package.mjs",
"makemessages-en": "formatjs extract 'src/**/*.{js,jsx}' --format bin/i18n-formatter.js --out-file src/i18n/messages/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'",
"makemessages-nl": "formatjs extract 'src/**/*.{js,jsx}' --format bin/i18n-formatter.js --out-file src/i18n/messages/nl.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'",
"makemessages": "npm run makemessages-nl && npm run makemessages-en",
Expand Down

0 comments on commit 3847a88

Please sign in to comment.