@graphcommerce/next-config 9.0.4-canary.0 β 9.0.4-canary.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.
- package/CHANGELOG.md +2 -12
- package/__tests__/commands/copyFiles.ts +8 -5
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +2 -1
- package/__tests__/config/utils/rewriteLegancyEnv.ts +1 -0
- package/__tests__/interceptors/findPlugins.ts +1 -0
- package/__tests__/interceptors/generateInterceptors.ts +1 -0
- package/__tests__/utils/resolveDependenciesSync.ts +1 -0
- package/dist/commands/codegen.js +3 -3
- package/dist/commands/copyFiles.js +12 -7
- package/dist/config/commands/generateConfig.js +1 -2
- package/dist/config/utils/mergeEnvIntoConfig.js +1 -3
- package/dist/generated/config.js +19 -15
- package/dist/interceptors/writeInterceptors.js +1 -1
- package/package.json +2 -1
- package/src/commands/codegen.ts +3 -3
- package/src/commands/copyFiles.ts +14 -7
- package/src/config/commands/generateConfig.ts +1 -2
- package/src/config/utils/mergeEnvIntoConfig.ts +1 -3
- package/src/generated/config.ts +293 -245
- package/src/interceptors/Visitor.ts +1 -1
- package/src/interceptors/findOriginalSource.ts +1 -1
- package/src/interceptors/writeInterceptors.ts +1 -1
- package/src/utils/resolveDependenciesSync.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.4-canary.1
|
|
4
|
+
|
|
3
5
|
## 9.0.4-canary.0
|
|
4
6
|
|
|
5
7
|
### Patch Changes
|
|
6
8
|
|
|
7
9
|
- [#2472](https://github.com/graphcommerce-org/graphcommerce/pull/2472) [`905157b`](https://github.com/graphcommerce-org/graphcommerce/commit/905157bec2c9e1dcf51b6e6f7b6913aa9be7b609) - Solve issue with chalk compilation because weβre not migrated to esm modules. ([@paales](https://github.com/paales))
|
|
8
10
|
|
|
9
|
-
## 9.0.3
|
|
10
|
-
|
|
11
|
-
## 9.0.3-canary.0
|
|
12
|
-
|
|
13
|
-
## 9.0.2
|
|
14
|
-
|
|
15
|
-
## 9.0.2-canary.0
|
|
16
|
-
|
|
17
|
-
## 9.0.1
|
|
18
|
-
|
|
19
|
-
## 9.0.1-canary.1
|
|
20
|
-
|
|
21
11
|
## 9.0.0
|
|
22
12
|
|
|
23
13
|
### Major Changes
|
|
@@ -31,6 +31,7 @@ global.performance = { now: mockPerformanceNow } as unknown as typeof performanc
|
|
|
31
31
|
|
|
32
32
|
// Mock process.cwd
|
|
33
33
|
const mockCwd = '/mock/cwd'
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
34
35
|
const originalCwd = process.cwd
|
|
35
36
|
beforeAll(() => {
|
|
36
37
|
process.cwd = jest.fn().mockReturnValue(mockCwd)
|
|
@@ -42,6 +43,7 @@ afterAll(() => {
|
|
|
42
43
|
|
|
43
44
|
describe('copyFiles', () => {
|
|
44
45
|
let consoleLog: jest.SpyInstance
|
|
46
|
+
let consoleInfo: jest.SpyInstance
|
|
45
47
|
let consoleError: jest.SpyInstance
|
|
46
48
|
let processExit: jest.SpyInstance
|
|
47
49
|
let originalDebug: string | undefined
|
|
@@ -57,6 +59,7 @@ describe('copyFiles', () => {
|
|
|
57
59
|
]),
|
|
58
60
|
)
|
|
59
61
|
consoleLog = jest.spyOn(console, 'log').mockImplementation(() => {})
|
|
62
|
+
consoleInfo = jest.spyOn(console, 'info').mockImplementation(() => {})
|
|
60
63
|
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
61
64
|
processExit = jest.spyOn(process, 'exit').mockImplementation(() => undefined as never)
|
|
62
65
|
|
|
@@ -205,7 +208,7 @@ describe('copyFiles', () => {
|
|
|
205
208
|
expect(writeCall).toBeTruthy()
|
|
206
209
|
const content = writeCall[1].toString()
|
|
207
210
|
expect(content).toContain('new content')
|
|
208
|
-
expect(
|
|
211
|
+
expect(consoleInfo).toHaveBeenCalledWith('Updated managed file: file.ts')
|
|
209
212
|
})
|
|
210
213
|
|
|
211
214
|
it('should create new files with management comments', async () => {
|
|
@@ -227,7 +230,7 @@ describe('copyFiles', () => {
|
|
|
227
230
|
|
|
228
231
|
await copyFiles()
|
|
229
232
|
|
|
230
|
-
expect(
|
|
233
|
+
expect(consoleInfo).toHaveBeenCalledWith(
|
|
231
234
|
'Creating new file: new-file.ts\nSource: packages/package1/copy/new-file.ts',
|
|
232
235
|
)
|
|
233
236
|
expect(fs.writeFile).toHaveBeenCalledWith(path.join(mockCwd, 'new-file.ts'), expect.any(Buffer))
|
|
@@ -374,8 +377,8 @@ describe('copyFiles', () => {
|
|
|
374
377
|
|
|
375
378
|
await copyFiles()
|
|
376
379
|
|
|
377
|
-
expect(
|
|
378
|
-
expect(
|
|
380
|
+
expect(consoleInfo).toHaveBeenCalledWith('[copy-files]', 'Starting copyFiles')
|
|
381
|
+
expect(consoleInfo).toHaveBeenCalledWith('[copy-files]', expect.stringContaining('Found'))
|
|
379
382
|
})
|
|
380
383
|
|
|
381
384
|
it('should handle unmanaged files', async () => {
|
|
@@ -397,7 +400,7 @@ describe('copyFiles', () => {
|
|
|
397
400
|
|
|
398
401
|
await copyFiles()
|
|
399
402
|
|
|
400
|
-
expect(
|
|
403
|
+
expect(consoleInfo).toHaveBeenCalledWith(
|
|
401
404
|
expect.stringContaining('Note: File file.ts has been modified'),
|
|
402
405
|
)
|
|
403
406
|
})
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import type { GraphCommerceConfig } from '../../../src/generated/config'
|
|
7
7
|
import { GraphCommerceConfigSchema } from '../../../src/generated/config'
|
|
8
8
|
import { removeColor } from './rewriteLegancyEnv'
|
|
9
|
+
|
|
9
10
|
const env = {
|
|
10
11
|
GC_ADVANCED_FILTERS: '0',
|
|
11
12
|
GC_DEMO_MODE: '1',
|
|
@@ -101,7 +102,7 @@ it('converts an env schema to a config schema', () => {
|
|
|
101
102
|
+ GC_STOREFRONT => storefront
|
|
102
103
|
~ GC_STOREFRONT_0_LOCALE => storefront.[0].locale"
|
|
103
104
|
`)
|
|
104
|
-
|
|
105
|
+
// Validate the resulting configura
|
|
105
106
|
const parsed = GraphCommerceConfigSchema().safeParse(mergedConfig)
|
|
106
107
|
expect(parsed.success).toBe(true)
|
|
107
108
|
if (parsed.success) {
|
|
@@ -2,6 +2,7 @@ import { formatAppliedEnv } from '../../../src/config/utils/mergeEnvIntoConfig'
|
|
|
2
2
|
import { rewriteLegacyEnv } from '../../../src/config/utils/rewriteLegacyEnv'
|
|
3
3
|
import type { GraphCommerceConfig } from '../../../src/generated/config'
|
|
4
4
|
import { GraphCommerceConfigSchema } from '../../../src/generated/config'
|
|
5
|
+
|
|
5
6
|
export const removeColor = (str: string) =>
|
|
6
7
|
str.replace(
|
|
7
8
|
new RegExp(
|
|
@@ -5,6 +5,7 @@ import { generateInterceptors } from '../../src/interceptors/generateInterceptor
|
|
|
5
5
|
import { parseStructure } from '../../src/interceptors/parseStructure'
|
|
6
6
|
import { parseSync } from '../../src/interceptors/swc'
|
|
7
7
|
import { resolveDependency } from '../../src/utils/resolveDependency'
|
|
8
|
+
|
|
8
9
|
const projectRoot = `${process.cwd()}/examples/magento-graphcms`
|
|
9
10
|
const startLocation = '/** @see {@link file://'
|
|
10
11
|
const expectImport = (value: string | undefined): jest.JestMatchers<string> =>
|
package/dist/commands/codegen.js
CHANGED
|
@@ -7,12 +7,12 @@ const copyFiles_1 = require("./copyFiles");
|
|
|
7
7
|
/** Run all code generation steps in sequence */
|
|
8
8
|
async function codegen() {
|
|
9
9
|
// Copy files from packages to project
|
|
10
|
-
console.
|
|
10
|
+
console.info('π Copying files from packages to project...');
|
|
11
11
|
await (0, copyFiles_1.copyFiles)();
|
|
12
12
|
// Generate GraphCommerce config types
|
|
13
|
-
console.
|
|
13
|
+
console.info('βοΈ Generating GraphCommerce config types...');
|
|
14
14
|
await (0, generateConfig_1.generateConfig)();
|
|
15
15
|
// Generate interceptors
|
|
16
|
-
console.
|
|
16
|
+
console.info('π Generating interceptors...');
|
|
17
17
|
await (0, codegenInterceptors_1.codegenInterceptors)();
|
|
18
18
|
}
|
|
@@ -12,7 +12,7 @@ const resolveDependenciesSync_1 = require("../utils/resolveDependenciesSync");
|
|
|
12
12
|
// Add debug logging helper
|
|
13
13
|
const debug = (...args) => {
|
|
14
14
|
if (process.env.DEBUG)
|
|
15
|
-
console.
|
|
15
|
+
console.info('[copy-files]', ...args);
|
|
16
16
|
};
|
|
17
17
|
// Add constants for the magic comments
|
|
18
18
|
const MANAGED_BY_GC = '// managed by: graphcommerce';
|
|
@@ -28,6 +28,11 @@ const GITIGNORE_SECTION_END = '# end managed by: graphcommerce';
|
|
|
28
28
|
* - Ensures the file ends with a newline
|
|
29
29
|
*/
|
|
30
30
|
async function updateGitignore(managedFiles) {
|
|
31
|
+
const escapedFiles = managedFiles
|
|
32
|
+
.map((file) =>
|
|
33
|
+
// Escape special characters in file names
|
|
34
|
+
file.replace(/[*+?^${}()|[\]\\]/g, '\\$&'))
|
|
35
|
+
.sort();
|
|
31
36
|
const gitignorePath = path_1.default.join(process.cwd(), '.gitignore');
|
|
32
37
|
let content;
|
|
33
38
|
try {
|
|
@@ -42,10 +47,10 @@ async function updateGitignore(managedFiles) {
|
|
|
42
47
|
const sectionRegex = new RegExp(`${GITIGNORE_SECTION_START}[\\s\\S]*?${GITIGNORE_SECTION_END}\\n?`, 'g');
|
|
43
48
|
content = content.replace(sectionRegex, '');
|
|
44
49
|
// Only add new section if there are files to manage
|
|
45
|
-
if (
|
|
50
|
+
if (escapedFiles.length > 0) {
|
|
46
51
|
const newSection = [
|
|
47
52
|
GITIGNORE_SECTION_START,
|
|
48
|
-
...
|
|
53
|
+
...escapedFiles,
|
|
49
54
|
GITIGNORE_SECTION_END,
|
|
50
55
|
'', // Empty line at the end
|
|
51
56
|
].join('\n');
|
|
@@ -180,7 +185,7 @@ Found in packages:
|
|
|
180
185
|
return;
|
|
181
186
|
}
|
|
182
187
|
if (management === 'unmanaged') {
|
|
183
|
-
console.
|
|
188
|
+
console.info(`Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`);
|
|
184
189
|
debug(`File ${file} doesn't have management comment, skipping`);
|
|
185
190
|
return;
|
|
186
191
|
}
|
|
@@ -192,7 +197,7 @@ Found in packages:
|
|
|
192
197
|
Source: ${sourcePath}`);
|
|
193
198
|
process.exit(1);
|
|
194
199
|
}
|
|
195
|
-
console.
|
|
200
|
+
console.info(`Creating new file: ${file}\nSource: ${sourcePath}`);
|
|
196
201
|
debug('File does not exist yet');
|
|
197
202
|
}
|
|
198
203
|
// Skip if content is identical (including magic comment)
|
|
@@ -204,7 +209,7 @@ Source: ${sourcePath}`);
|
|
|
204
209
|
// Copy the file with magic comment
|
|
205
210
|
await promises_1.default.writeFile(targetPath, contentWithComment);
|
|
206
211
|
if (targetContent) {
|
|
207
|
-
console.
|
|
212
|
+
console.info(`Updated managed file: ${file}`);
|
|
208
213
|
debug(`Overwrote existing file: ${file}`);
|
|
209
214
|
}
|
|
210
215
|
// If the file is managed by GraphCommerce (new or updated), add it to managedFiles
|
|
@@ -258,7 +263,7 @@ Source: ${sourcePath}`);
|
|
|
258
263
|
// Then try to remove the file
|
|
259
264
|
try {
|
|
260
265
|
await promises_1.default.unlink(filePath);
|
|
261
|
-
console.
|
|
266
|
+
console.info(`Removed managed file: ${file}`);
|
|
262
267
|
debug(`Removed file: ${file}`);
|
|
263
268
|
}
|
|
264
269
|
catch (err) {
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateConfig = generateConfig;
|
|
7
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
7
|
const fs_1 = require("fs");
|
|
9
8
|
const cli_1 = require("@graphql-codegen/cli");
|
|
10
9
|
const core_1 = require("@swc/core");
|
|
@@ -51,7 +50,7 @@ async function generateConfig() {
|
|
|
51
50
|
});
|
|
52
51
|
const result = (0, core_1.transformFileSync)(targetTs, {
|
|
53
52
|
module: { type: 'commonjs' },
|
|
54
|
-
env: { targets: { node: '
|
|
53
|
+
env: { targets: { node: '18' } },
|
|
55
54
|
});
|
|
56
55
|
(0, fs_1.writeFileSync)(targetJs, result.code);
|
|
57
56
|
}
|
|
@@ -150,9 +150,7 @@ function mergeEnvIntoConfig(schema, config, env) {
|
|
|
150
150
|
function formatAppliedEnv(applyResult) {
|
|
151
151
|
let hasError = false;
|
|
152
152
|
let hasWarning = false;
|
|
153
|
-
const lines = applyResult.map(({ from, to,
|
|
154
|
-
const fromFmt = chalk_1.default.red(JSON.stringify(from));
|
|
155
|
-
const toFmt = chalk_1.default.green(JSON.stringify(to));
|
|
153
|
+
const lines = applyResult.map(({ from, to, envVar, dotVar, error, warning }) => {
|
|
156
154
|
const envVariableFmt = `${envVar}`;
|
|
157
155
|
const dotVariableFmt = chalk_1.default.bold.underline(`${dotVar}`);
|
|
158
156
|
const baseLog = `${envVariableFmt} => ${dotVariableFmt}`;
|
package/dist/generated/config.js
CHANGED
|
@@ -18,14 +18,18 @@ exports.definedNonNullAnySchema = zod_1.z.any().refine((v) => (0, exports.isDefi
|
|
|
18
18
|
exports.CartPermissionsSchema = zod_1.z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']);
|
|
19
19
|
exports.CompareVariantSchema = zod_1.z.enum(['CHECKBOX', 'ICON']);
|
|
20
20
|
exports.ContainerSizingSchema = zod_1.z.enum(['BREAKPOINT', 'FULL_WIDTH']);
|
|
21
|
-
exports.CustomerAccountPermissionsSchema = zod_1.z.enum([
|
|
21
|
+
exports.CustomerAccountPermissionsSchema = zod_1.z.enum([
|
|
22
|
+
'DISABLED',
|
|
23
|
+
'DISABLE_REGISTRATION',
|
|
24
|
+
'ENABLED',
|
|
25
|
+
]);
|
|
22
26
|
exports.PaginationVariantSchema = zod_1.z.enum(['COMPACT', 'EXTENDED']);
|
|
23
27
|
exports.ProductFiltersLayoutSchema = zod_1.z.enum(['DEFAULT', 'SIDEBAR']);
|
|
24
28
|
exports.SidebarGalleryPaginationVariantSchema = zod_1.z.enum(['DOTS', 'THUMBNAILS_BOTTOM']);
|
|
25
29
|
exports.WebsitePermissionsSchema = zod_1.z.enum(['ENABLED']);
|
|
26
30
|
function DatalayerConfigSchema() {
|
|
27
31
|
return zod_1.z.object({
|
|
28
|
-
coreWebVitals: zod_1.z.boolean().nullish()
|
|
32
|
+
coreWebVitals: zod_1.z.boolean().nullish(),
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
function GraphCommerceConfigSchema() {
|
|
@@ -34,11 +38,11 @@ function GraphCommerceConfigSchema() {
|
|
|
34
38
|
canonicalBaseUrl: zod_1.z.string().min(1),
|
|
35
39
|
cartDisplayPricesInclTax: zod_1.z.boolean().nullish(),
|
|
36
40
|
compare: zod_1.z.boolean().nullish(),
|
|
37
|
-
compareVariant: exports.CompareVariantSchema.default(
|
|
41
|
+
compareVariant: exports.CompareVariantSchema.default('ICON').nullish(),
|
|
38
42
|
configurableVariantForSimple: zod_1.z.boolean().default(false).nullish(),
|
|
39
43
|
configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(),
|
|
40
|
-
containerSizingContent: exports.ContainerSizingSchema.default(
|
|
41
|
-
containerSizingShell: exports.ContainerSizingSchema.default(
|
|
44
|
+
containerSizingContent: exports.ContainerSizingSchema.default('FULL_WIDTH').nullish(),
|
|
45
|
+
containerSizingShell: exports.ContainerSizingSchema.default('FULL_WIDTH').nullish(),
|
|
42
46
|
crossSellsHideCartItems: zod_1.z.boolean().default(false).nullish(),
|
|
43
47
|
crossSellsRedirectItems: zod_1.z.boolean().default(false).nullish(),
|
|
44
48
|
customerAddressNoteEnable: zod_1.z.boolean().nullish(),
|
|
@@ -62,16 +66,16 @@ function GraphCommerceConfigSchema() {
|
|
|
62
66
|
magentoVersion: zod_1.z.number(),
|
|
63
67
|
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
64
68
|
previewSecret: zod_1.z.string().nullish(),
|
|
65
|
-
productFiltersLayout: exports.ProductFiltersLayoutSchema.default(
|
|
69
|
+
productFiltersLayout: exports.ProductFiltersLayoutSchema.default('DEFAULT').nullish(),
|
|
66
70
|
productFiltersPro: zod_1.z.boolean().nullish(),
|
|
67
|
-
productListPaginationVariant: exports.PaginationVariantSchema.default(
|
|
71
|
+
productListPaginationVariant: exports.PaginationVariantSchema.default('COMPACT').nullish(),
|
|
68
72
|
productRoute: zod_1.z.string().nullish(),
|
|
69
73
|
recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(),
|
|
70
74
|
robotsAllow: zod_1.z.boolean().nullish(),
|
|
71
75
|
sidebarGallery: SidebarGalleryConfigSchema().nullish(),
|
|
72
76
|
storefront: zod_1.z.array(GraphCommerceStorefrontConfigSchema()),
|
|
73
77
|
wishlistHideForGuests: zod_1.z.boolean().nullish(),
|
|
74
|
-
wishlistShowFeedbackMessage: zod_1.z.boolean().nullish()
|
|
78
|
+
wishlistShowFeedbackMessage: zod_1.z.boolean().nullish(),
|
|
75
79
|
});
|
|
76
80
|
}
|
|
77
81
|
function GraphCommerceDebugConfigSchema() {
|
|
@@ -80,13 +84,13 @@ function GraphCommerceDebugConfigSchema() {
|
|
|
80
84
|
pluginStatus: zod_1.z.boolean().nullish(),
|
|
81
85
|
sessions: zod_1.z.boolean().nullish(),
|
|
82
86
|
webpackCircularDependencyPlugin: zod_1.z.boolean().nullish(),
|
|
83
|
-
webpackDuplicatesPlugin: zod_1.z.boolean().nullish()
|
|
87
|
+
webpackDuplicatesPlugin: zod_1.z.boolean().nullish(),
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
90
|
function GraphCommerceGooglePlaystoreConfigSchema() {
|
|
87
91
|
return zod_1.z.object({
|
|
88
92
|
packageName: zod_1.z.string().min(1),
|
|
89
|
-
sha256CertificateFingerprint: zod_1.z.string().min(1)
|
|
93
|
+
sha256CertificateFingerprint: zod_1.z.string().min(1),
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
function GraphCommercePermissionsSchema() {
|
|
@@ -94,7 +98,7 @@ function GraphCommercePermissionsSchema() {
|
|
|
94
98
|
cart: exports.CartPermissionsSchema.nullish(),
|
|
95
99
|
checkout: exports.CartPermissionsSchema.nullish(),
|
|
96
100
|
customerAccount: exports.CustomerAccountPermissionsSchema.nullish(),
|
|
97
|
-
website: exports.WebsitePermissionsSchema.nullish()
|
|
101
|
+
website: exports.WebsitePermissionsSchema.nullish(),
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
function GraphCommerceStorefrontConfigSchema() {
|
|
@@ -112,24 +116,24 @@ function GraphCommerceStorefrontConfigSchema() {
|
|
|
112
116
|
locale: zod_1.z.string().min(1),
|
|
113
117
|
magentoStoreCode: zod_1.z.string().min(1),
|
|
114
118
|
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
115
|
-
robotsAllow: zod_1.z.boolean().nullish()
|
|
119
|
+
robotsAllow: zod_1.z.boolean().nullish(),
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
122
|
function MagentoConfigurableVariantValuesSchema() {
|
|
119
123
|
return zod_1.z.object({
|
|
120
124
|
content: zod_1.z.boolean().nullish(),
|
|
121
125
|
gallery: zod_1.z.boolean().nullish(),
|
|
122
|
-
url: zod_1.z.boolean().nullish()
|
|
126
|
+
url: zod_1.z.boolean().nullish(),
|
|
123
127
|
});
|
|
124
128
|
}
|
|
125
129
|
function RecentlyViewedProductsConfigSchema() {
|
|
126
130
|
return zod_1.z.object({
|
|
127
131
|
enabled: zod_1.z.boolean().nullish(),
|
|
128
|
-
maxCount: zod_1.z.number().nullish()
|
|
132
|
+
maxCount: zod_1.z.number().nullish(),
|
|
129
133
|
});
|
|
130
134
|
}
|
|
131
135
|
function SidebarGalleryConfigSchema() {
|
|
132
136
|
return zod_1.z.object({
|
|
133
|
-
paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish()
|
|
137
|
+
paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish(),
|
|
134
138
|
});
|
|
135
139
|
}
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeInterceptors = writeInterceptors;
|
|
7
7
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
|
-
const glob_1 = require("glob");
|
|
9
8
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
10
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const glob_1 = require("glob");
|
|
11
11
|
const resolveDependenciesSync_1 = require("../utils/resolveDependenciesSync");
|
|
12
12
|
function checkFileExists(file) {
|
|
13
13
|
return promises_1.default
|
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": "9.0.4-canary.
|
|
5
|
+
"version": "9.0.4-canary.1",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "src/index.ts",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"prepack": "tsc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@graphql-codegen/cli": "5.0.3",
|
|
15
16
|
"@swc/core": "1.10.1",
|
|
16
17
|
"@swc/wasm-web": "^1.10.1",
|
|
17
18
|
"@types/circular-dependency-plugin": "^5.0.8",
|
package/src/commands/codegen.ts
CHANGED
|
@@ -5,14 +5,14 @@ import { copyFiles } from './copyFiles'
|
|
|
5
5
|
/** Run all code generation steps in sequence */
|
|
6
6
|
export async function codegen() {
|
|
7
7
|
// Copy files from packages to project
|
|
8
|
-
console.
|
|
8
|
+
console.info('π Copying files from packages to project...')
|
|
9
9
|
await copyFiles()
|
|
10
10
|
|
|
11
11
|
// Generate GraphCommerce config types
|
|
12
|
-
console.
|
|
12
|
+
console.info('βοΈ Generating GraphCommerce config types...')
|
|
13
13
|
await generateConfig()
|
|
14
14
|
|
|
15
15
|
// Generate interceptors
|
|
16
|
-
console.
|
|
16
|
+
console.info('π Generating interceptors...')
|
|
17
17
|
await codegenInterceptors()
|
|
18
18
|
}
|
|
@@ -6,7 +6,7 @@ import { resolveDependenciesSync } from '../utils/resolveDependenciesSync'
|
|
|
6
6
|
|
|
7
7
|
// Add debug logging helper
|
|
8
8
|
const debug = (...args: unknown[]) => {
|
|
9
|
-
if (process.env.DEBUG) console.
|
|
9
|
+
if (process.env.DEBUG) console.info('[copy-files]', ...args)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// Add constants for the magic comments
|
|
@@ -25,6 +25,13 @@ const GITIGNORE_SECTION_END = '# end managed by: graphcommerce'
|
|
|
25
25
|
* - Ensures the file ends with a newline
|
|
26
26
|
*/
|
|
27
27
|
async function updateGitignore(managedFiles: string[]) {
|
|
28
|
+
const escapedFiles = managedFiles
|
|
29
|
+
.map((file) =>
|
|
30
|
+
// Escape special characters in file names
|
|
31
|
+
file.replace(/[*+?^${}()|[\]\\]/g, '\\$&'),
|
|
32
|
+
)
|
|
33
|
+
.sort()
|
|
34
|
+
|
|
28
35
|
const gitignorePath = path.join(process.cwd(), '.gitignore')
|
|
29
36
|
let content: string
|
|
30
37
|
|
|
@@ -44,10 +51,10 @@ async function updateGitignore(managedFiles: string[]) {
|
|
|
44
51
|
content = content.replace(sectionRegex, '')
|
|
45
52
|
|
|
46
53
|
// Only add new section if there are files to manage
|
|
47
|
-
if (
|
|
54
|
+
if (escapedFiles.length > 0) {
|
|
48
55
|
const newSection = [
|
|
49
56
|
GITIGNORE_SECTION_START,
|
|
50
|
-
...
|
|
57
|
+
...escapedFiles,
|
|
51
58
|
GITIGNORE_SECTION_END,
|
|
52
59
|
'', // Empty line at the end
|
|
53
60
|
].join('\n')
|
|
@@ -206,7 +213,7 @@ Found in packages:
|
|
|
206
213
|
return
|
|
207
214
|
}
|
|
208
215
|
if (management === 'unmanaged') {
|
|
209
|
-
console.
|
|
216
|
+
console.info(
|
|
210
217
|
`Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`,
|
|
211
218
|
)
|
|
212
219
|
debug(`File ${file} doesn't have management comment, skipping`)
|
|
@@ -220,7 +227,7 @@ Found in packages:
|
|
|
220
227
|
Source: ${sourcePath}`)
|
|
221
228
|
process.exit(1)
|
|
222
229
|
}
|
|
223
|
-
console.
|
|
230
|
+
console.info(`Creating new file: ${file}\nSource: ${sourcePath}`)
|
|
224
231
|
debug('File does not exist yet')
|
|
225
232
|
}
|
|
226
233
|
|
|
@@ -234,7 +241,7 @@ Source: ${sourcePath}`)
|
|
|
234
241
|
// Copy the file with magic comment
|
|
235
242
|
await fs.writeFile(targetPath, contentWithComment)
|
|
236
243
|
if (targetContent) {
|
|
237
|
-
console.
|
|
244
|
+
console.info(`Updated managed file: ${file}`)
|
|
238
245
|
debug(`Overwrote existing file: ${file}`)
|
|
239
246
|
}
|
|
240
247
|
|
|
@@ -293,7 +300,7 @@ Source: ${sourcePath}`)
|
|
|
293
300
|
// Then try to remove the file
|
|
294
301
|
try {
|
|
295
302
|
await fs.unlink(filePath)
|
|
296
|
-
console.
|
|
303
|
+
console.info(`Removed managed file: ${file}`)
|
|
297
304
|
debug(`Removed file: ${file}`)
|
|
298
305
|
} catch (err) {
|
|
299
306
|
if ((err as { code?: string }).code !== 'ENOENT') {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
1
|
import { writeFileSync } from 'fs'
|
|
3
2
|
import { generate } from '@graphql-codegen/cli'
|
|
4
3
|
import { transformFileSync } from '@swc/core'
|
|
@@ -52,7 +51,7 @@ export async function generateConfig() {
|
|
|
52
51
|
|
|
53
52
|
const result = transformFileSync(targetTs, {
|
|
54
53
|
module: { type: 'commonjs' },
|
|
55
|
-
env: { targets: { node: '
|
|
54
|
+
env: { targets: { node: '18' } },
|
|
56
55
|
})
|
|
57
56
|
|
|
58
57
|
writeFileSync(targetJs, result.code)
|
|
@@ -204,9 +204,7 @@ export function mergeEnvIntoConfig(
|
|
|
204
204
|
export function formatAppliedEnv(applyResult: ApplyResult) {
|
|
205
205
|
let hasError = false
|
|
206
206
|
let hasWarning = false
|
|
207
|
-
const lines = applyResult.map(({ from, to,
|
|
208
|
-
const fromFmt = chalk.red(JSON.stringify(from))
|
|
209
|
-
const toFmt = chalk.green(JSON.stringify(to))
|
|
207
|
+
const lines = applyResult.map(({ from, to, envVar, dotVar, error, warning }) => {
|
|
210
208
|
const envVariableFmt = `${envVar}`
|
|
211
209
|
const dotVariableFmt = chalk.bold.underline(`${dotVar}`)
|
|
212
210
|
|