From 685e88c5a0351cf2a6a41090cf88a2da4c7075fc Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 12:55:43 +0300 Subject: [PATCH 01/13] adapted files to work with docs-utils' migration to ES modules --- gatsby-config.js | 4 ++-- gatsby-node.js | 6 +++--- package.json | 1 + sample-runner/shared/MainPanel.js | 2 +- scripts/DocParser.js | 28 ++++++++++++++-------------- scripts/clean.js | 2 +- scripts/make-runner.js | 12 ++++++------ scripts/prepareRaw.js | 8 ++++---- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 87eae4bf..30e1d869 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,8 +1,8 @@ /* eslint-env node */ /* eslint-disable camelcase */ -const path = require('path'); +import path from 'path'; -module.exports = { +export default { pathPrefix: '/', siteMetadata: { title: 'Enact' diff --git a/gatsby-node.js b/gatsby-node.js index 8e680cb3..f9ff4d2a 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -2,9 +2,9 @@ // const GracefulFSPlugin = require('graceful-fs-webpack-plugin'); // const autoprefixer = require('autoprefixer'); // const FilterWarningsPlugin = require("webpack-filter-warnings-plugin"); -const webpack = require('webpack'); -const crypto = require('crypto'); -const path = require('path'); +import crypto from 'crypto'; +import path from 'path'; +import webpack from 'webpack'; exports.onCreateWebpackConfig = ({ stage, diff --git a/package.json b/package.json index 3b127261..c397375b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "docs", "description": "Enact JavaScript Framework Docs", + "type": "module", "version": "4.5.0", "engines": { "node": ">=14" diff --git a/sample-runner/shared/MainPanel.js b/sample-runner/shared/MainPanel.js index ffcdc4ce..4b5c6f04 100644 --- a/sample-runner/shared/MainPanel.js +++ b/sample-runner/shared/MainPanel.js @@ -1,5 +1,5 @@ import kind from '@enact/core/kind'; -import EnactLiveEdit from './EnactLiveEdit'; +import EnactLiveEdit from './EnactLiveEdit.js'; const MainPanel = kind({ name: 'Main', diff --git a/scripts/DocParser.js b/scripts/DocParser.js index 459a8cda..e197e6ee 100644 --- a/scripts/DocParser.js +++ b/scripts/DocParser.js @@ -11,18 +11,18 @@ /* eslint-env node */ 'use strict'; -const parseArgs = require('minimist'), - chokidar = require('chokidar'), - { - getValidFiles, - getDocumentation, - postValidate, - copyStaticDocs, - generateIndex, - getDocsConfig, - extractLibraryDescription, - saveLibraryDescriptions - } = require('@enact/docs-utils'); +import chokidar from 'chokidar'; +import { + copyStaticDocs, + extractLibraryDescription, + generateIndex, + getDocsConfig, + getDocumentation, + getValidFiles, + postValidate, + saveLibraryDescriptions +} from '@enact/docs-utils'; +import parseArgs from 'minimist'; const dataDir = 'src/data'; const docIndexFile = `${dataDir}/docIndex.json`; @@ -47,7 +47,7 @@ function sourceFilter (module) { // eslint-disable-line no-shadow return module.parseSource; } -function init () { +async function init () { const args = parseArgs(process.argv); const strict = args.strict, extraRepos = args['extra-repos'], @@ -63,7 +63,7 @@ function init () { }); } - require('./prepareRaw'); // populate `raw` directory with source + await import('./prepareRaw.js'); // populate `raw` directory with source const moduleConfigs = modulePaths.map(getDocsConfig); diff --git a/scripts/clean.js b/scripts/clean.js index 8704df97..a6baa27b 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -1,4 +1,4 @@ -const shelljs = require('shelljs'); +import shelljs from 'shelljs'; shelljs.config.silent = true; const leaveIndex = (dir, basePath = 'src/pages/docs/') => { diff --git a/scripts/make-runner.js b/scripts/make-runner.js index 99a998eb..4b7301bb 100644 --- a/scripts/make-runner.js +++ b/scripts/make-runner.js @@ -10,13 +10,13 @@ /* eslint-env node */ 'use strict'; -const shell = require('shelljs'), - fs = require('fs'), - parseArgs = require('minimist'); +import fs from 'fs'; +import parseArgs from 'minimist'; +import shell from 'shelljs'; -const allLibraries = require('../src/data/libraryDescription.json'), - includes = ['core', 'moonstone', 'sandstone', 'agate'], - themes = Object.keys(allLibraries).filter(name => includes.includes(name)); +const allLibraries = JSON.parse(fs.readFileSync('./src/data/libraryDescription.json')); +const includes = ['core', 'moonstone', 'sandstone', 'agate']; +const themes = Object.keys(allLibraries).filter(name => includes.includes(name)); const args = parseArgs(process.argv), fast = args.fast, diff --git a/scripts/prepareRaw.js b/scripts/prepareRaw.js index 7e7066de..8dc14876 100644 --- a/scripts/prepareRaw.js +++ b/scripts/prepareRaw.js @@ -10,10 +10,10 @@ * Additional repos can be pulled into the docs using the following command line arg: * * `extra-repos` (e.g. --extra-repos enactjs/agate#develop,enactjs/moonstone#3.2.5) */ -const shell = require('shelljs'), - parseArgs = require('minimist'), - // eslint-disable-next-line no-shadow - process = require('process'); +import parseArgs from 'minimist'; +// eslint-disable-next-line no-shadow +import process from 'process'; +import shell from 'shelljs'; if (!shell.which('git')) { shell.echo('Sorry, this script requires git'); From d4853ee8dbb4e619571af8c24fcbfd94dff69e08 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 13:42:27 +0300 Subject: [PATCH 02/13] adjusted import --- sample-runner/shared/MainPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-runner/shared/MainPanel.js b/sample-runner/shared/MainPanel.js index 4b5c6f04..23ec019d 100644 --- a/sample-runner/shared/MainPanel.js +++ b/sample-runner/shared/MainPanel.js @@ -1,4 +1,4 @@ -import kind from '@enact/core/kind'; +import kind from '@enact/core/kind.js'; import EnactLiveEdit from './EnactLiveEdit.js'; const MainPanel = kind({ From d5613c0f852b2a770a6a0523cf5691b97d97f8ad Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 13:56:38 +0300 Subject: [PATCH 03/13] undid import adjustment --- sample-runner/shared/MainPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-runner/shared/MainPanel.js b/sample-runner/shared/MainPanel.js index 23ec019d..4b5c6f04 100644 --- a/sample-runner/shared/MainPanel.js +++ b/sample-runner/shared/MainPanel.js @@ -1,4 +1,4 @@ -import kind from '@enact/core/kind.js'; +import kind from '@enact/core/kind'; import EnactLiveEdit from './EnactLiveEdit.js'; const MainPanel = kind({ From 8bc9feee9b8ad13c76d7126e06b2404e74016aa9 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 14:23:16 +0300 Subject: [PATCH 04/13] adjusted import --- sample-runner/shared/MainPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-runner/shared/MainPanel.js b/sample-runner/shared/MainPanel.js index 4b5c6f04..ff143791 100644 --- a/sample-runner/shared/MainPanel.js +++ b/sample-runner/shared/MainPanel.js @@ -1,4 +1,4 @@ -import kind from '@enact/core/kind'; +import kind from '@enact/core/kind/kind.js'; import EnactLiveEdit from './EnactLiveEdit.js'; const MainPanel = kind({ From cf812acc3e5bedb9b76b19677a0ccb201f966591 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 14:44:53 +0300 Subject: [PATCH 05/13] "__dirname is not defined" fix --- gatsby-config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gatsby-config.js b/gatsby-config.js index 30e1d869..583ddf21 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,6 +1,20 @@ /* eslint-env node */ /* eslint-disable camelcase */ import path from 'path'; +import {fileURLToPath} from 'url'; + +export function getFilename(metaUrl) { + const __filename = fileURLToPath(metaUrl); + + return __filename; +} +export function getDirname(metaUrl) { + const __dirname = path.dirname(getFilename(metaUrl)); + + return __dirname; +} + +const __dirname = getDirname(import.meta.url); export default { pathPrefix: '/', From cc846f3c86fee716e7530932af22ec78f684f43e Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 15:00:27 +0300 Subject: [PATCH 06/13] fixed travis errors and warnings --- gatsby-config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 583ddf21..0cea31f2 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -3,15 +3,15 @@ import path from 'path'; import {fileURLToPath} from 'url'; -export function getFilename(metaUrl) { - const __filename = fileURLToPath(metaUrl); +export function getFilename (metaUrl) { + const __filenameVar = fileURLToPath(metaUrl); - return __filename; + return __filenameVar; } -export function getDirname(metaUrl) { - const __dirname = path.dirname(getFilename(metaUrl)); +export function getDirname (metaUrl) { + const __dirnameVar = path.dirname(getFilename(metaUrl)); - return __dirname; + return __dirnameVar; } const __dirname = getDirname(import.meta.url); From 654762d98ae561ca051889e9637b17023aaafaa7 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 15:11:02 +0300 Subject: [PATCH 07/13] lint error fix --- gatsby-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatsby-config.js b/gatsby-config.js index 0cea31f2..c50a977d 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -14,7 +14,7 @@ export function getDirname (metaUrl) { return __dirnameVar; } -const __dirname = getDirname(import.meta.url); +__dirname = getDirname(import.meta.url); export default { pathPrefix: '/', From 2eef644bfaae63d2fd48a22eb504997b783c5dfc Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 15:20:24 +0300 Subject: [PATCH 08/13] renamed __dirname const --- gatsby-config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index c50a977d..8cb5480f 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -14,7 +14,7 @@ export function getDirname (metaUrl) { return __dirnameVar; } -__dirname = getDirname(import.meta.url); +const __dirnameConst = getDirname(import.meta.url); export default { pathPrefix: '/', @@ -42,7 +42,7 @@ export default { resolve: 'gatsby-source-filesystem', options: { name: 'pages', - path: path.join(__dirname, 'src', 'pages') + path: path.join(__dirnameConst, 'src', 'pages') } }, { From 9546f969c2eb14a2be00aebbe14ee373ca1234ec Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Thu, 18 May 2023 15:49:49 +0300 Subject: [PATCH 09/13] refactored file with common js extension --- gatsby-node.js => gatsby-node.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename gatsby-node.js => gatsby-node.cjs (100%) diff --git a/gatsby-node.js b/gatsby-node.cjs similarity index 100% rename from gatsby-node.js rename to gatsby-node.cjs From 86c12d442b2ed9ac06e5602f45deaebb8b4c5f9e Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Fri, 26 May 2023 14:25:13 +0300 Subject: [PATCH 10/13] undo renaming gatsby-node.cjs --- gatsby-node.cjs => gatsby-node.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename gatsby-node.cjs => gatsby-node.js (100%) diff --git a/gatsby-node.cjs b/gatsby-node.js similarity index 100% rename from gatsby-node.cjs rename to gatsby-node.js From 47aa942dece206b8e9a3466747a65763b53eb12f Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Fri, 26 May 2023 14:33:50 +0300 Subject: [PATCH 11/13] adapted gatsby-node.js for es modules --- gatsby-node.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index f9ff4d2a..9db1fc24 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -6,7 +6,7 @@ import crypto from 'crypto'; import path from 'path'; import webpack from 'webpack'; -exports.onCreateWebpackConfig = ({ +export const onCreateWebpackConfig = ({ stage, loaders, plugins, @@ -75,7 +75,7 @@ exports.modifyWebpackConfig = ({config, stage}) => { }; */ -exports.onCreateBabelConfig = ({actions}) => { +export const onCreateBabelConfig = ({actions}) => { actions.setBabelPlugin({ name: '@babel/plugin-transform-react-jsx', options: { @@ -84,7 +84,7 @@ exports.onCreateBabelConfig = ({actions}) => { }); }; -function createSlug ({relativePath}) { +export function createSlug ({relativePath}) { let slug; const parsedFilePath = path.parse(relativePath); if (parsedFilePath.name !== 'index' && parsedFilePath.dir !== '') { @@ -97,7 +97,7 @@ function createSlug ({relativePath}) { return slug; } -async function onCreateNode ({node, actions, getNode, loadNodeContent}) { +export async function onCreateNode ({node, actions, getNode, loadNodeContent}) { const {createNodeField, createNode, createParentChildLink} = actions; let slug; if (node.internal.type === 'MarkdownRemark') { @@ -141,9 +141,9 @@ async function onCreateNode ({node, actions, getNode, loadNodeContent}) { } } -exports.onCreateNode = onCreateNode; +export const onCreateNode = onCreateNode; -exports.createPages = ({graphql, actions}) => { +export const createPages = ({graphql, actions}) => { const {createPage} = actions; // Create a regex that will include siblings and (if applicable) parent's siblings, but not From fdbd6d0e842de2c0b7aa4b904967a6131c132081 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Fri, 26 May 2023 15:48:40 +0300 Subject: [PATCH 12/13] deleted duplicate declaration --- gatsby-node.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 9db1fc24..f61ece0c 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -84,7 +84,7 @@ export const onCreateBabelConfig = ({actions}) => { }); }; -export function createSlug ({relativePath}) { +function createSlug ({relativePath}) { let slug; const parsedFilePath = path.parse(relativePath); if (parsedFilePath.name !== 'index' && parsedFilePath.dir !== '') { @@ -141,8 +141,6 @@ export async function onCreateNode ({node, actions, getNode, loadNodeContent}) { } } -export const onCreateNode = onCreateNode; - export const createPages = ({graphql, actions}) => { const {createPage} = actions; From 50cc83377df13c0a679a5d3a7622f87a83038e39 Mon Sep 17 00:00:00 2001 From: Stanca Pop Date: Wed, 14 Jun 2023 16:42:49 +0300 Subject: [PATCH 13/13] testing with gatsby packages update --- package.json | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index f2897865..d0780fec 100644 --- a/package.json +++ b/package.json @@ -21,28 +21,28 @@ "css-loader": "^6.7.3", "elasticlunr": "^0.9.5", "find-cache-dir": "^3.3.2", - "gatsby": "^5.8.0", - "gatsby-plugin-catch-links": "^5.8.0", - "gatsby-plugin-google-gtag": "^5.8.0", - "gatsby-plugin-image": "^3.8.0", - "gatsby-plugin-less": "^7.8.0", - "gatsby-plugin-manifest": "^5.8.0", - "gatsby-plugin-offline": "^6.8.0", - "gatsby-plugin-postcss": "^6.8.0", - "gatsby-plugin-react-helmet": "^6.8.0", - "gatsby-plugin-sharp": "^5.8.1", - "gatsby-plugin-typography": "^5.8.0", - "gatsby-remark-autolink-headers": "^6.8.0", - "gatsby-remark-copy-linked-files": "^6.8.0", + "gatsby": "^5.10.0", + "gatsby-plugin-catch-links": "^5.10.0", + "gatsby-plugin-google-gtag": "^5.10.0", + "gatsby-plugin-image": "^3.10.0", + "gatsby-plugin-less": "^7.10.0", + "gatsby-plugin-manifest": "^5.10.0", + "gatsby-plugin-offline": "^6.10.0", + "gatsby-plugin-postcss": "^6.10.0", + "gatsby-plugin-react-helmet": "^6.10.0", + "gatsby-plugin-sharp": "^5.10.0", + "gatsby-plugin-typography": "^5.10.0", + "gatsby-remark-autolink-headers": "^6.10.0", + "gatsby-remark-copy-linked-files": "^6.10.0", "gatsby-remark-embed-youtube": "0.0.7", - "gatsby-remark-images": "^7.8.0", - "gatsby-remark-prismjs": "^7.8.0", - "gatsby-remark-responsive-iframe": "^6.8.0", - "gatsby-remark-smartypants": "^6.8.0", - "gatsby-source-filesystem": "^5.8.0", - "gatsby-transformer-javascript-frontmatter": "^5.8.0", - "gatsby-transformer-json": "^5.8.0", - "gatsby-transformer-remark": "^6.8.0", + "gatsby-remark-images": "^7.10.0", + "gatsby-remark-prismjs": "^7.10.0", + "gatsby-remark-responsive-iframe": "^6.10.0", + "gatsby-remark-smartypants": "^6.10.0", + "gatsby-source-filesystem": "^5.10.0", + "gatsby-transformer-javascript-frontmatter": "^5.10.0", + "gatsby-transformer-json": "^5.10.0", + "gatsby-transformer-remark": "^6.10.0", "global-modules": "^2.0.0", "gray-matter": "^4.0.3", "json-loader": "^0.5.7",