@graphcommerce/next-config 10.0.0-canary.56 → 10.0.0-canary.57

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.0-canary.57
4
+
3
5
  ## 10.0.0-canary.56
4
6
 
5
7
  ### Major Changes
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import dotenv from 'dotenv';
2
- import fs from 'node:fs/promises';
2
+ import fs from 'fs/promises';
3
3
  import path from 'path';
4
4
  import { glob, sync } from 'glob';
5
5
  import { findParentPath } from './utils/findParentPath.js';
@@ -7,17 +7,14 @@ import { spawn } from 'child_process';
7
7
  import { l as loadConfig, t as toEnvStr } from './loadConfig-nJiCKeL1.js';
8
8
  export { r as replaceConfigInString } from './loadConfig-nJiCKeL1.js';
9
9
  import { parseFileSync, parseSync as parseSync$1, transformFileSync } from '@swc/core';
10
- import fs$1 from 'node:fs';
11
- import path$1 from 'node:path';
10
+ import fs$1, { writeFileSync, readFileSync, existsSync, rmSync, mkdirSync } from 'fs';
12
11
  import assert from 'assert';
13
12
  import crypto from 'crypto';
14
13
  import lodash from 'lodash';
15
14
  import { z } from 'zod';
16
15
  import prettierConf from '@graphcommerce/prettier-config-pwa';
17
16
  import prettier from 'prettier';
18
- import fs$2 from 'fs/promises';
19
17
  import fg from 'fast-glob';
20
- import { writeFileSync, readFileSync, existsSync, rmSync, mkdirSync } from 'fs';
21
18
  import { generate } from '@graphql-codegen/cli';
22
19
  import { GraphCommerceConfigSchema } from './generated/config.js';
23
20
  export { GraphCommerceDebugConfigSchema, GraphCommerceStorefrontConfigSchema } from './generated/config.js';
@@ -253,11 +250,11 @@ const resolveCache = /* @__PURE__ */ new Map();
253
250
  function findPackageJson(id, root) {
254
251
  let dir = id.startsWith("/") ? id : import.meta.resolve(id);
255
252
  if (dir.startsWith("file://")) dir = new URL(dir).pathname;
256
- let packageJsonLocation = path$1.join(dir, "package.json");
253
+ let packageJsonLocation = path.join(dir, "package.json");
257
254
  while (!fs$1.existsSync(packageJsonLocation)) {
258
- dir = path$1.dirname(dir);
255
+ dir = path.dirname(dir);
259
256
  if (dir === root) throw Error(`Can't find package.json for ${id}`);
260
- packageJsonLocation = path$1.join(dir, "package.json");
257
+ packageJsonLocation = path.join(dir, "package.json");
261
258
  }
262
259
  return packageJsonLocation;
263
260
  }
@@ -305,7 +302,7 @@ function resolveRecursivePackageJson(dependencyPath, dependencyStructure, root,
305
302
  });
306
303
  const name = isRoot ? "." : packageJson.name;
307
304
  dependencyStructure[name] = {
308
- dirName: path$1.dirname(path$1.relative(process.cwd(), fileName)),
305
+ dirName: path.dirname(path.relative(process.cwd(), fileName)),
309
306
  dependencies: availableDependencies
310
307
  };
311
308
  return dependencyStructure;
@@ -844,7 +841,7 @@ async function generateInterceptors(plugins, resolve, config, force) {
844
841
  if (pluginPath.startsWith(".")) {
845
842
  const resolvedPlugin = resolve(pluginPath);
846
843
  if (resolvedPlugin) {
847
- pluginPath = path$1.relative(
844
+ pluginPath = path.relative(
848
845
  resolved.fromRoot.split("/").slice(0, -1).join("/"),
849
846
  resolvedPlugin.fromRoot
850
847
  );
@@ -970,22 +967,22 @@ async function updatePackageExports(plugins, cwd = process.cwd()) {
970
967
  console.log(`\u{1F50D} Scanning ${roots.length} package roots for plugins...`);
971
968
  const pluginsByPackage = /* @__PURE__ */ new Map();
972
969
  for (const root of roots) {
973
- const packageDirs = sync(`${root}/*/package.json`).map((pkgPath) => path$1.dirname(pkgPath));
970
+ const packageDirs = sync(`${root}/*/package.json`).map((pkgPath) => path.dirname(pkgPath));
974
971
  for (const packagePath of packageDirs) {
975
972
  const pluginFiles = sync(`${packagePath}/plugins/**/*.{ts,tsx}`);
976
973
  if (pluginFiles.length > 0) {
977
974
  const exportPaths = /* @__PURE__ */ new Set();
978
975
  pluginFiles.forEach((file) => {
979
- const relativePath = path$1.relative(packagePath, file);
976
+ const relativePath = path.relative(packagePath, file);
980
977
  const exportPath = `./${relativePath.replace(/\.(ts|tsx)$/, "")}`;
981
978
  exportPaths.add(exportPath);
982
979
  });
983
980
  if (exportPaths.size > 0) {
984
- const packageJsonPath = path$1.join(packagePath, "package.json");
981
+ const packageJsonPath = path.join(packagePath, "package.json");
985
982
  try {
986
983
  const packageJsonContent = await fs.readFile(packageJsonPath, "utf8");
987
984
  const packageJson = JSON.parse(packageJsonContent);
988
- const packageName = packageJson.name || path$1.basename(packagePath);
985
+ const packageName = packageJson.name || path.basename(packagePath);
989
986
  pluginsByPackage.set(packagePath, exportPaths);
990
987
  } catch (error) {
991
988
  console.warn(`\u26A0\uFE0F Could not read package.json for ${packagePath}:`, error);
@@ -997,7 +994,7 @@ async function updatePackageExports(plugins, cwd = process.cwd()) {
997
994
  console.log(`\u{1F4E6} Total packages with plugins: ${pluginsByPackage.size}`);
998
995
  const updatePromises = Array.from(pluginsByPackage.entries()).map(
999
996
  async ([packagePath, exportPaths]) => {
1000
- const packageJsonPath = path$1.join(packagePath, "package.json");
997
+ const packageJsonPath = path.join(packagePath, "package.json");
1001
998
  try {
1002
999
  const packageJsonContent = await fs.readFile(packageJsonPath, "utf8");
1003
1000
  const packageJson = JSON.parse(packageJsonContent);
@@ -1012,7 +1009,7 @@ async function updatePackageExports(plugins, cwd = process.cwd()) {
1012
1009
  const exportKey = exportPath.startsWith("./") ? exportPath : `./${exportPath}`;
1013
1010
  const filePath = `${exportPath}.tsx`;
1014
1011
  const tsFilePath = `${exportPath}.ts`;
1015
- const targetFile = sync(path$1.join(packagePath, `${exportPath.slice(2)}.{ts,tsx}`))[0];
1012
+ const targetFile = sync(path.join(packagePath, `${exportPath.slice(2)}.{ts,tsx}`))[0];
1016
1013
  if (targetFile) {
1017
1014
  const extension = targetFile.endsWith(".tsx") ? ".tsx" : ".ts";
1018
1015
  const targetPath = `${exportPath}${extension}`;
@@ -1079,7 +1076,7 @@ async function updateGitignore(managedFiles) {
1079
1076
  const gitignorePath = path.join(process.cwd(), ".gitignore");
1080
1077
  let content;
1081
1078
  try {
1082
- content = await fs$2.readFile(gitignorePath, "utf-8");
1079
+ content = await fs.readFile(gitignorePath, "utf-8");
1083
1080
  debug("Reading existing .gitignore");
1084
1081
  } catch (err) {
1085
1082
  debug(".gitignore not found, creating new file");
@@ -1107,7 +1104,7 @@ ${newSection}`;
1107
1104
  `;
1108
1105
  debug("Cleaned up .gitignore managed section");
1109
1106
  }
1110
- await fs$2.writeFile(gitignorePath, content);
1107
+ await fs.writeFile(gitignorePath, content);
1111
1108
  }
1112
1109
  function getFileManagement(content) {
1113
1110
  if (!content) return "graphcommerce";
@@ -1148,7 +1145,7 @@ async function copyFiles() {
1148
1145
  allFiles.map(async (file) => {
1149
1146
  const filePath = path.join(cwd, file);
1150
1147
  try {
1151
- const content = await fs$2.readFile(filePath);
1148
+ const content = await fs.readFile(filePath);
1152
1149
  if (getFileManagement(content) === "graphcommerce") {
1153
1150
  existingManagedFiles.add(file);
1154
1151
  debug(`Found existing managed file: ${file}`);
@@ -1202,8 +1199,8 @@ Path: ${copyDir}`
1202
1199
  const targetPath = path.join(cwd, file);
1203
1200
  debug(`Processing file: ${file}`);
1204
1201
  try {
1205
- await fs$2.mkdir(path.dirname(targetPath), { recursive: true });
1206
- const sourceContent = await fs$2.readFile(sourcePath);
1202
+ await fs.mkdir(path.dirname(targetPath), { recursive: true });
1203
+ const sourceContent = await fs.readFile(sourcePath);
1207
1204
  const contentWithComment = Buffer.concat([
1208
1205
  Buffer.from(
1209
1206
  `${MANAGED_BY_GC}
@@ -1215,7 +1212,7 @@ Path: ${copyDir}`
1215
1212
  ]);
1216
1213
  let targetContent;
1217
1214
  try {
1218
- targetContent = await fs$2.readFile(targetPath);
1215
+ targetContent = await fs.readFile(targetPath);
1219
1216
  const management = getFileManagement(targetContent);
1220
1217
  if (management === "local") {
1221
1218
  debug(`File ${file} is managed locally, skipping`);
@@ -1244,7 +1241,7 @@ Source: ${sourcePath}`);
1244
1241
  managedFiles.add(file);
1245
1242
  return;
1246
1243
  }
1247
- await fs$2.writeFile(targetPath, contentWithComment);
1244
+ await fs.writeFile(targetPath, contentWithComment);
1248
1245
  if (targetContent) {
1249
1246
  console.info(`Updated managed file: ${file}`);
1250
1247
  debug(`Overwrote existing file: ${file}`);
@@ -1268,9 +1265,9 @@ Source: ${sourcePath}`);
1268
1265
  let currentDir = startPath;
1269
1266
  while (currentDir !== cwd) {
1270
1267
  try {
1271
- const dirContents = await fs$2.readdir(currentDir);
1268
+ const dirContents = await fs.readdir(currentDir);
1272
1269
  if (dirContents.length === 0) {
1273
- await fs$2.rmdir(currentDir);
1270
+ await fs.rmdir(currentDir);
1274
1271
  debug(`Removed empty directory: ${currentDir}`);
1275
1272
  currentDir = path.dirname(currentDir);
1276
1273
  } else {
@@ -1290,9 +1287,9 @@ Source: ${sourcePath}`);
1290
1287
  const filePath = path.join(cwd, file);
1291
1288
  const dirPath = path.dirname(filePath);
1292
1289
  try {
1293
- await fs$2.readdir(dirPath);
1290
+ await fs.readdir(dirPath);
1294
1291
  try {
1295
- await fs$2.unlink(filePath);
1292
+ await fs.unlink(filePath);
1296
1293
  console.info(`Removed managed file: ${file}`);
1297
1294
  debug(`Removed file: ${file}`);
1298
1295
  } catch (err) {
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
1
+ import fs from 'fs';
2
+ import path from 'path';
3
3
 
4
4
  const debug = process.env.DEBUG === "1";
5
5
  const log = (message) => debug && console.log(`isMonorepo: ${message}`);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-config",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "10.0.0-canary.56",
5
+ "version": "10.0.0-canary.57",
6
6
  "type": "module",
7
7
  "types": "./src/index.ts",
8
8
  "exports": {
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@apollo/client": "*",
67
- "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.56",
67
+ "@graphcommerce/prettier-config-pwa": "^10.0.0-canary.57",
68
68
  "@lingui/loader": "*",
69
69
  "@lingui/macro": "*",
70
70
  "@lingui/react": "*",
@@ -1,6 +1,6 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- import fs from 'node:fs/promises'
3
- import path from 'node:path'
2
+ import fs from 'fs/promises'
3
+ import path from 'path'
4
4
  import type { GraphCommerceDebugConfig } from '../generated/config'
5
5
  import type { ResolveDependency } from '../utils/resolveDependency'
6
6
  import { findOriginalSource } from './findOriginalSource'
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs/promises'
2
- import path from 'node:path'
1
+ import fs from 'fs/promises'
2
+ import path from 'path'
3
3
  import { sync as globSync } from 'glob'
4
4
  import { packageRoots } from '../utils'
5
5
  import { resolveDependenciesSync } from '../utils/resolveDependenciesSync'
@@ -1,5 +1,5 @@
1
- import { stat } from 'node:fs'
2
- import fs from 'node:fs/promises'
1
+ import { stat } from 'fs'
2
+ import fs from 'fs/promises'
3
3
  import path from 'path'
4
4
  import { glob } from 'glob'
5
5
  import { findParentPath } from '../utils/findParentPath'
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
1
+ import fs from 'fs'
2
+ import path from 'path'
3
3
 
4
4
  const debug = process.env.DEBUG === '1'
5
5
  // eslint-disable-next-line no-console
@@ -1,5 +1,5 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
1
+ import fs from 'fs'
2
+ import path from 'path'
3
3
  import type { PackageJson } from 'type-fest'
4
4
  import { PackagesSort } from './PackagesSort'
5
5
  import { sig } from './sig'
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs'
1
+ import fs from 'fs'
2
2
  import { resolveDependenciesSync } from './resolveDependenciesSync'
3
3
 
4
4
  export type ResolveDependencyReturn =