@imtf/profile-scripts 1.1.0 → 1.1.1

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.
@@ -1,39 +1,39 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const concurrently = require('concurrently');
4
- const spawn = require('cross-spawn');
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ const spawn = require("cross-spawn");
5
5
 
6
6
  const args = process.argv.slice(2);
7
- const scriptIndex = args.findIndex((x) => x === 'build' || x === 'start');
7
+ const scriptIndex = args.findIndex((x) => x === "build" || x === "start");
8
8
  const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
9
9
 
10
10
  const scriptPath = require.resolve(`../scripts/esbuild.mjs`);
11
11
 
12
12
  switch (script) {
13
- case 'start':
14
- case 'build': {
13
+ case "start":
14
+ case "build": {
15
15
  const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
16
16
  const scriptArgs = args.slice(scriptIndex + 1);
17
17
 
18
- if (script === 'start') {
19
- scriptArgs.push('--watch');
18
+ if (script === "start") {
19
+ scriptArgs.push("--watch");
20
20
  }
21
21
 
22
22
  const processArgs = nodeArgs.concat(scriptPath).concat(scriptArgs);
23
23
 
24
- const child = spawn.sync('node', processArgs, {
25
- stdio: 'inherit',
26
- env: { ...process.env, NODE_ENV: 'production' },
24
+ const child = spawn.sync("node", processArgs, {
25
+ stdio: "inherit",
26
+ env: { ...process.env, NODE_ENV: "production" },
27
27
  });
28
28
 
29
29
  if (child.signal) {
30
- if (child.signal === 'SIGKILL') {
30
+ if (child.signal === "SIGKILL") {
31
31
  console.log(`
32
32
  The build failed because the process exited too early.
33
33
  This probably means the system ran out of memory or someone called
34
34
  \`kill -9\` on the process.
35
35
  `);
36
- } else if (child.signal === 'SIGTERM') {
36
+ } else if (child.signal === "SIGTERM") {
37
37
  console.log(`
38
38
  The build failed because the process exited too early.
39
39
  Someone might have called \`kill\` or \`killall\`, or the system could
package/changelog.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Here you can find a resume of all changes between versions.
4
4
 
5
+ ## 1.1.1
6
+
7
+ ### Chores
8
+
9
+ - Upgraded dependencies
10
+
5
11
  ## 1.1.0
6
12
 
7
13
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imtf/profile-scripts",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Default scripts to bundle & transpile imtf front-end plugins",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -12,27 +12,29 @@
12
12
  "changelog.md"
13
13
  ],
14
14
  "scripts": {
15
- "build": "NODE_ENV=production node scripts/esbuild.mjs",
16
- "start": "node scripts/esbuild.mjs --watch"
15
+ "build": "NODE_ENV=production node scripts/esbuild.mjs --entryPoint=index.tsx",
16
+ "start": "node scripts/esbuild.mjs --entryPoint=index.tsx --watch"
17
17
  },
18
18
  "eslintConfig": {
19
- "extends": "@imtf/eslint-config-react"
19
+ "extends": "@imtf/eslint-config-react",
20
+ "rules": {
21
+ "import/default": "off"
22
+ }
20
23
  },
21
24
  "prettier": "@imtf/prettier-config",
22
- "author": "Luca Pillonel",
23
25
  "license": "UNLICENSED",
24
26
  "private": false,
25
27
  "dependencies": {
26
- "@svgr/core": "^7.0.0",
27
- "@svgr/plugin-jsx": "^7.0.0",
28
- "@svgr/plugin-svgo": "^7.0.0",
28
+ "@svgr/core": "^8.0.0",
29
+ "@svgr/plugin-jsx": "^8.0.1",
30
+ "@svgr/plugin-svgo": "^8.0.1",
29
31
  "concurrently": "^8.0.1",
30
- "esbuild": "^0.17.16",
32
+ "esbuild": "^0.18.6",
31
33
  "esbuild-plugin-external-global": "^1.0.1",
32
34
  "serve": "^14.1.2"
33
35
  },
34
36
  "devDependencies": {
35
- "@imtf/eslint-config-react": "^1.0.0",
36
- "@imtf/prettier-config": "^2.0.0"
37
+ "@imtf/eslint-config-react": "^3.0.0",
38
+ "@imtf/prettier-config": "^3.0.0"
37
39
  }
38
40
  }
@@ -1,54 +1,57 @@
1
- import { context, build } from 'esbuild';
2
- import externalGlobalPlugin from 'esbuild-plugin-external-global';
3
- import minimist from 'minimist';
1
+ import { build, context } from "esbuild";
2
+ import esbuild from "esbuild-plugin-external-global";
3
+ import minimist from "minimist";
4
4
 
5
- import notifierPlugin from './notifierPlugin.mjs';
6
- import svgPlugin from './svgPlugin.mjs';
5
+ // eslint-disable-next-line import/no-named-as-default-member
6
+ const externalGlobalPlugin = esbuild.externalGlobalPlugin;
7
+
8
+ import notifierPlugin from "./notifierPlugin.mjs";
9
+ import svgPlugin from "./svgPlugin.mjs";
7
10
 
8
11
  const { watch, entryPoint } = minimist(process.argv.slice(2));
9
12
 
10
13
  const entryPoints = entryPoint
11
- ? typeof entryPoint === 'string'
14
+ ? typeof entryPoint === "string"
12
15
  ? [entryPoint]
13
16
  : entryPoint
14
- : ['src/index.js'];
17
+ : ["src/index.js"];
15
18
 
16
19
  /**
17
20
  * @type {import('esbuild').BuildOptions}
18
21
  */
19
22
  const config = {
20
23
  entryPoints,
21
- outdir: 'build',
22
- platform: 'browser',
24
+ outdir: "build",
25
+ platform: "browser",
23
26
  bundle: true,
24
- target: 'es2020',
27
+ target: "es2020",
25
28
 
26
29
  minify:
27
- process.env.NODE_ENV === 'production' &&
28
- process.env.IMTF_MINIFY_WEBAPP !== 'false',
30
+ process.env.NODE_ENV === "production" &&
31
+ process.env.IMTF_MINIFY_WEBAPP !== "false",
29
32
 
30
33
  loader: {
31
- '.css': 'text',
34
+ ".css": "text",
32
35
  // Enable JSX in .js files too
33
- '.js': 'jsx',
36
+ ".js": "jsx",
34
37
  // Embed fonts
35
- '.eot': 'dataurl',
36
- '.ttf': 'dataurl',
37
- '.woff': 'dataurl',
38
- '.woff2': 'dataurl',
38
+ ".eot": "dataurl",
39
+ ".ttf": "dataurl",
40
+ ".woff": "dataurl",
41
+ ".woff2": "dataurl",
39
42
  // Embed images
40
- '.gif': 'dataurl',
41
- '.jpg': 'dataurl',
42
- '.png': 'dataurl',
43
+ ".gif": "dataurl",
44
+ ".jpg": "dataurl",
45
+ ".png": "dataurl",
43
46
  },
44
47
 
45
48
  plugins: [
46
49
  svgPlugin(),
47
- externalGlobalPlugin.externalGlobalPlugin({
48
- react: 'window.React',
49
- 'react-dom': 'window.ReactDOM',
50
- 'react-router-dom': 'window.reactRouterDom',
51
- IMTFPlugins: 'window.IMTFPlugins',
50
+ externalGlobalPlugin({
51
+ react: "window.React",
52
+ "react-dom": "window.ReactDOM",
53
+ "react-router-dom": "window.reactRouterDom",
54
+ IMTFPlugins: "window.IMTFPlugins",
52
55
  }),
53
56
  notifierPlugin(),
54
57
  ],
@@ -1,20 +1,20 @@
1
- const notifierPlugin = (options = {}) => ({
2
- name: 'svgr',
1
+ const notifierPlugin = () => ({
2
+ name: "svgr",
3
3
  setup(build) {
4
- let count = 0
4
+ let count = 0;
5
5
 
6
- build.onEnd(result => {
6
+ build.onEnd((result) => {
7
7
  if (result.errors.length > 0) {
8
- return
8
+ return;
9
9
  }
10
10
 
11
11
  if (count++ === 0) {
12
- console.log(`1st build: ${new Date().getTime()}`)
12
+ console.log(`1st build: ${new Date().getTime()}`);
13
13
  } else {
14
- console.log(`Rebuilt: ${new Date().getTime()}`)
14
+ console.log(`Rebuilt: ${new Date().getTime()}`);
15
15
  }
16
- })
16
+ });
17
17
  },
18
- })
18
+ });
19
19
 
20
- export default notifierPlugin
20
+ export default notifierPlugin;
@@ -1,44 +1,44 @@
1
- import { transform } from '@svgr/core'
2
- import fs from 'fs'
3
- import path from 'path'
1
+ import { transform } from "@svgr/core";
2
+ import fs from "fs";
3
+ import path from "path";
4
4
 
5
5
  const svgPlugin = (options = {}) => ({
6
- name: 'svgr',
6
+ name: "svgr",
7
7
  setup(build) {
8
- build.onLoad({ filter: /\.svg$/ }, async args => {
8
+ build.onLoad({ filter: /\.svg$/ }, async (args) => {
9
9
  // Read file content
10
- const svg = await fs.promises.readFile(args.path, 'utf8')
10
+ const svg = await fs.promises.readFile(args.path, "utf8");
11
11
 
12
12
  // Determine relative path
13
- const relativePath = path.relative(process.cwd(), args.path)
13
+ const relativePath = path.relative(process.cwd(), args.path);
14
14
 
15
15
  // This is an asset ==> dataurl
16
16
  if (
17
- !relativePath.startsWith('src/') ||
18
- relativePath.startsWith('src/assets/')
17
+ !relativePath.startsWith("src/") ||
18
+ relativePath.startsWith("src/assets/")
19
19
  ) {
20
20
  return {
21
21
  contents: svg,
22
- loader: 'dataurl',
23
- }
22
+ loader: "dataurl",
23
+ };
24
24
  }
25
25
 
26
26
  // Otherwise it's a react component
27
27
  const contents = await transform(
28
28
  svg,
29
29
  {
30
- plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
30
+ plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
31
31
  ...options,
32
32
  },
33
33
  { filePath: args.path }
34
- )
34
+ );
35
35
 
36
36
  return {
37
37
  contents,
38
- loader: 'jsx',
39
- }
40
- })
38
+ loader: "jsx",
39
+ };
40
+ });
41
41
  },
42
- })
42
+ });
43
43
 
44
- export default svgPlugin
44
+ export default svgPlugin;