Skip to content

Commit

Permalink
convert to type=module
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Feb 14, 2024
1 parent 8c509c9 commit a2e083b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
28 changes: 17 additions & 11 deletions package.json
Expand Up @@ -9,22 +9,22 @@
"type": "git",
"url": "https://github.com/storybookjs/storybook-addon-kit"
},
"type": "module",
"license": "MIT",
"author": "package-author",
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": "./dist/index.js",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./manager": "./dist/manager.mjs",
"./preview": "./dist/preview.mjs",
"./preview": {
"types": "./dist/index.d.ts",
"import": "./dist/preview.js"
},
"./manager": "./dist/manager.js",
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand Down Expand Up @@ -84,9 +84,15 @@
"access": "public"
},
"bundler": {
"exportEntries": ["src/index.ts"],
"managerEntries": ["src/manager.ts"],
"previewEntries": ["src/preview.ts"]
"exportEntries": [
"src/index.ts"
],
"managerEntries": [
"src/manager.ts"
],
"previewEntries": [
"src/preview.ts"
]
},
"storybook": {
"displayName": "Addon Kit",
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 15 additions & 11 deletions scripts/welcome.js
@@ -1,10 +1,14 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable no-console */
const prompts = require("prompts");
const dedent = require("ts-dedent").default;
const path = require("path");
const fs = require("fs");
const { execSync } = require("child_process");
import prompts from 'prompts';
import { dedent } from 'ts-dedent';
import { dirname, resolve } from 'path';
import { readFileSync, writeFileSync } from 'fs';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// CLI questions
const questions = [
Expand Down Expand Up @@ -128,10 +132,10 @@ const main = async () => {

const authorField = authorName + (authorEmail ? ` <${authorEmail}>` : "");

const packageJson = path.resolve(__dirname, `../package.json`);
const packageJson = resolve(__dirname, `../package.json`);

console.log(`\n👷 Updating package.json...`);
let packageJsonContents = fs.readFileSync(packageJson, "utf-8");
let packageJsonContents = readFileSync(packageJson, "utf-8");

packageJsonContents = packageJsonContents
.replace(REPLACE_TEMPLATES.packageName, packageName)
Expand All @@ -143,11 +147,11 @@ const main = async () => {
.replace(REPLACE_TEMPLATES.supportedFrameworks, supportedFrameworks)
.replace(/\s*"postinstall".*node.*scripts\/welcome.js.*",/, '');

fs.writeFileSync(packageJson, packageJsonContents);
writeFileSync(packageJson, packageJsonContents);

console.log("📝 Updating the README...");
const readme = path.resolve(__dirname, `../README.md`);
let readmeContents = fs.readFileSync(readme, "utf-8");
const readme = resolve(__dirname, `../README.md`);
let readmeContents = readFileSync(readme, "utf-8");

const regex = /<\!-- README START -->([\s\S]*)<\!-- README END -->/g;

Expand All @@ -159,7 +163,7 @@ const main = async () => {
`
);

fs.writeFileSync(readme, readmeContents);
writeFileSync(readme, readmeContents);

console.log(`📦 Creating a commit...`);
execSync('git add . && git commit -m "project setup" --no-verify');
Expand Down

0 comments on commit a2e083b

Please sign in to comment.