@m2c2kit/core 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@m2c2kit/core",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "The m2c2kit core functionality",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
+ "type": "module",
7
8
  "exports": {
8
9
  ".": {
9
10
  "import": "./dist/index.js"
@@ -13,32 +14,30 @@
13
14
  "dist/index.js",
14
15
  "dist/index.d.ts",
15
16
  "assets/**",
16
- "index.html",
17
- "post-install.mjs"
17
+ "index.html"
18
18
  ],
19
19
  "scripts": {
20
20
  "build": "npm run clean && tsc && rollup -c",
21
- "clean": "rimraf build build-nobundler build-umd dist .rollup.cache tsconfig.tsbuildinfo",
22
- "test": "jest",
23
- "postinstall": "node post-install.mjs"
21
+ "clean": "rimraf build build-nobundler dist .rollup.cache tsconfig.tsbuildinfo coverage",
22
+ "test": "cd ../.. && npx env-cmd -f .env.jest jest --selectProjects @m2c2kit/core"
24
23
  },
25
24
  "license": "MIT",
26
25
  "devDependencies": {
27
- "@rollup/plugin-babel": "6.0.3",
28
- "@rollup/plugin-commonjs": "24.1.0",
26
+ "@rollup/plugin-commonjs": "25.0.0",
29
27
  "@rollup/plugin-node-resolve": "15.0.2",
30
28
  "@rollup/plugin-replace": "5.0.2",
31
29
  "@types/jest": "29.5.1",
32
30
  "@types/jsdom": "21.1.1",
33
31
  "canvas": "2.11.2",
34
- "canvaskit-wasm": "0.38.0",
35
- "esbuild": "0.17.17",
32
+ "canvaskit-wasm": "0.38.1",
33
+ "cross-env": "7.0.3",
34
+ "env-cmd": "10.1.0",
36
35
  "findup-sync": "5.0.0",
37
36
  "jest": "29.5.0",
38
37
  "jest-environment-jsdom": "29.5.0",
39
- "jsdom": "21.1.1",
38
+ "jsdom": "22.0.0",
40
39
  "rimraf": "5.0.0",
41
- "rollup": "3.20.6",
40
+ "rollup": "3.22.0",
42
41
  "rollup-plugin-copy": "3.4.0",
43
42
  "rollup-plugin-dts": "5.3.0",
44
43
  "rollup-plugin-esbuild": "5.0.0",
package/post-install.mjs DELETED
@@ -1,98 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readFileSync, existsSync } from "fs";
3
- import { resolve, join, dirname, basename } from "path";
4
- import { env, exit } from "process";
5
- import { readdir, readFile, mkdir, writeFile } from "fs/promises";
6
-
7
- /**
8
- * Our current working directory for this postinstall script is the
9
- * package's root folder in node_modules, e.g., node_modules/{packageName}
10
- */
11
-
12
- /**
13
- * The folder in which npm command was executed -- this differs from the
14
- * current working directory.
15
- */
16
- const npmCwd = env.INIT_CWD;
17
-
18
- /**
19
- * If the full m2c2kit repo has been cloned and "npm install" is executed,
20
- * when this package is installed it will run this post-install script.
21
- * But, we should run this only when the package is being installed in a
22
- * new m2c2kit project, because it will copy assets to the
23
- * appropriate location in the project root. The below code will check if
24
- * npm install is being run on the entire m2c2kit repo, and if so, exit this
25
- * script before copying any assets.
26
- * Note: this will cause problems if someone decides to name their m2c2kit
27
- * project "m2c2kit".
28
- */
29
- const { name } = JSON.parse(readFileSync(join(npmCwd, "package.json")));
30
- if (name === "m2c2kit") {
31
- exit(0);
32
- }
33
-
34
- async function copyFolderRecursive(options) {
35
- async function getFilePathsRecursive(dir) {
36
- const dirents = await readdir(dir, { withFileTypes: true });
37
- const files = await Promise.all(
38
- dirents.map((dirent) => {
39
- const res = resolve(dir, dirent.name);
40
- return dirent.isDirectory() ? getFilePathsRecursive(res) : res;
41
- })
42
- );
43
- return Array.prototype.concat(...files);
44
- }
45
-
46
- const filePaths = await getFilePathsRecursive(options.sourceFolder);
47
-
48
- filePaths.forEach(async (filePath) => {
49
- const destinationFilePath = join(
50
- options.destinationFolder,
51
- filePath.replace(resolve(options.sourceFolder), options.baseFolder)
52
- );
53
- if (!options.overwrite && existsSync(destinationFilePath)) {
54
- return;
55
- }
56
-
57
- const folder = dirname(destinationFilePath);
58
- if (!existsSync(folder)) {
59
- await mkdir(folder, { recursive: true });
60
- }
61
-
62
- const content = await readFile(filePath);
63
- await writeFile(destinationFilePath, content);
64
- });
65
- }
66
-
67
- async function copyFile(options) {
68
- if (
69
- !options.overwrite &&
70
- existsSync(
71
- join(options.destinationFolder, basename(options.sourceFilePath))
72
- )
73
- ) {
74
- return;
75
- }
76
-
77
- const content = await readFile(options.sourceFilePath);
78
-
79
- if (!existsSync(options.destinationFolder)) {
80
- await mkdir(options.destinationFolder, { recursive: true });
81
- }
82
- await writeFile(
83
- join(options.destinationFolder, basename(options.sourceFilePath)),
84
- content
85
- );
86
- }
87
-
88
- copyFolderRecursive({
89
- sourceFolder: "assets",
90
- destinationFolder: join(npmCwd, "src"),
91
- baseFolder: "assets",
92
- overwrite: false,
93
- });
94
- copyFile({
95
- sourceFilePath: "index.html",
96
- destinationFolder: join(npmCwd, "src"),
97
- overwrite: false,
98
- });