Skip to content

Commit d06bf4f

Browse files
committed
fix(core): update build config
1 parent 385d3f0 commit d06bf4f

File tree

4 files changed

+222
-24
lines changed

4 files changed

+222
-24
lines changed

package-lock.json

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/docs-site/docs/changelog.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@ hide_title: true
55
sidebar_position: 2
66
slug: /changelog
77
---
8+
## 1.2.0 (2025-08-22)
9+
10+
### 🚀 Features
11+
12+
- bump nx version ([bdd397b](https://github.com/agentender/nx-github-pages/commit/bdd397b))
13+
14+
### ❤️ Thank You
15+
16+
- Craigory Coppola @AgentEnder
17+
18+
## 1.1.1 (2025-08-22)
19+
20+
21+
### 🩹 Fixes
22+
23+
- **nx-github-pages:** correct build config s.t. executors work ([7ed482c](https://github.com/agentender/nx-github-pages/commit/7ed482c))
24+
25+
### ❤️ Thank You
26+
27+
- Craigory Coppola @AgentEnder
28+
29+
## 1.1.0 (2025-08-22)
30+
31+
32+
### 🚀 Features
33+
34+
- **nx-github-pages:** allow setting git user info in executor options ([a5de2f9](https://github.com/agentender/nx-github-pages/commit/a5de2f9))
35+
36+
### 🩹 Fixes
37+
38+
- **nx-github-pages:** fixup provenance setup ([13c7014](https://github.com/agentender/nx-github-pages/commit/13c7014))
39+
40+
### ❤️ Thank You
41+
42+
- Craigory Coppola @AgentEnder
43+
844
## 1.0.1 (2025-08-22)
945

1046

packages/e2e/src/nx-github-pages.spec.ts

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
44
import { ProjectConfiguration, workspaceRoot } from '@nx/devkit';
55

66
describe('nx-github-pages', () => {
7-
let projectDirectory, remote, remoteDirectory: string;
7+
let projectDirectory: string;
8+
let remote: string;
9+
let remoteDirectory: string;
810

911
// The state of the remote matters for some tests so we
1012
// are going to reinit everything everytime. This is not the most
@@ -26,15 +28,21 @@ describe('nx-github-pages', () => {
2628
});
2729

2830
it('should deploy to gh-pages branch of remote', () => {
29-
generateReactApp(projectDirectory, 'my-app');
31+
const appName = 'my-app';
32+
const nxProjectName = getNxProjectName(projectDirectory, appName);
33+
generateReactApp(projectDirectory, appName);
3034

3135
runCommand(
32-
'npx nx g nx-github-pages:configuration --project my-app --user.name deployment-bot --user.email deployment@testing.com --no-interactive',
36+
`npx nx g nx-github-pages:configuration --project ${nxProjectName} --user.name deployment-bot --user.email deployment@testing.com --no-interactive`,
3337
projectDirectory,
3438
{}
3539
);
3640

37-
runCommand('npx nx deploy my-app --no-interactive', projectDirectory, {});
41+
runCommand(
42+
`npx nx deploy ${nxProjectName} --no-interactive`,
43+
projectDirectory,
44+
{}
45+
);
3846

3947
// Check that the gh-pages branch exists in the remote
4048
runCommand('git checkout gh-pages', remoteDirectory, {});
@@ -46,32 +54,66 @@ describe('nx-github-pages', () => {
4654
});
4755

4856
it('should sync via merge sync enabled and deployment already exists', () => {
57+
const appName = 'my-app';
58+
const nxProjectName = getNxProjectName(projectDirectory, appName);
59+
4960
// SETUP
5061
// Create a new app
51-
generateReactApp(projectDirectory, 'my-app');
62+
generateReactApp(projectDirectory, appName);
5263
// Create the configuration
5364
runCommand(
54-
'npx nx g nx-github-pages:configuration --user.name deployment-bot --user.email deployment@testing.com --project my-app --no-interactive',
65+
`npx nx g nx-github-pages:configuration --user.name deployment-bot --user.email deployment@testing.com --project ${nxProjectName} --no-interactive`,
5566
projectDirectory,
5667
{}
5768
);
5869
// Initial deployment
59-
runCommand('npx nx deploy my-app --no-interactive', projectDirectory, {});
60-
// enable sync settings
61-
updateJsonFile<ProjectConfiguration>(
70+
runCommand(
71+
`npx nx deploy ${nxProjectName} --no-interactive`,
6272
projectDirectory,
63-
'apps/my-app/project.json',
64-
(json) => {
65-
json.targets.deploy.options.syncWithBaseBranch = true;
66-
json.targets.deploy.options.syncGitOptions = [
67-
'--allow-unrelated-histories',
68-
'-s ours',
69-
];
70-
return json;
71-
}
73+
{}
7274
);
73-
// Update the app
74-
updateFile(projectDirectory, 'apps/my-app/src/index.html', (content) =>
75+
// enable sync settings — Nx 22+ stores project config in package.json under "nx"
76+
const projectConfigPath = existsSync(
77+
join(projectDirectory, `apps/${appName}/project.json`)
78+
)
79+
? `apps/${appName}/project.json`
80+
: `apps/${appName}/package.json`;
81+
const isPackageJson = projectConfigPath.endsWith('package.json');
82+
83+
if (isPackageJson) {
84+
updateJsonFile<{ nx: ProjectConfiguration }>(
85+
projectDirectory,
86+
projectConfigPath,
87+
(json) => {
88+
json.nx.targets.deploy.options.syncWithBaseBranch = true;
89+
json.nx.targets.deploy.options.syncGitOptions = [
90+
'--allow-unrelated-histories',
91+
'-s ours',
92+
];
93+
return json;
94+
}
95+
);
96+
} else {
97+
updateJsonFile<ProjectConfiguration>(
98+
projectDirectory,
99+
projectConfigPath,
100+
(json) => {
101+
json.targets.deploy.options.syncWithBaseBranch = true;
102+
json.targets.deploy.options.syncGitOptions = [
103+
'--allow-unrelated-histories',
104+
'-s ours',
105+
];
106+
return json;
107+
}
108+
);
109+
}
110+
// Update the app — Nx 22+ with Vite puts index.html at the app root
111+
const indexHtmlPath = existsSync(
112+
join(projectDirectory, `apps/${appName}/index.html`)
113+
)
114+
? `apps/${appName}/index.html`
115+
: `apps/${appName}/src/index.html`;
116+
updateFile(projectDirectory, indexHtmlPath, (content) =>
75117
content.replace(
76118
'<div id="root"></div>',
77119
'<h1>Updated</h1><div id="root"></div>'
@@ -80,7 +122,11 @@ describe('nx-github-pages', () => {
80122

81123
// TEST
82124
// Deploy the updated app
83-
runCommand('npx nx deploy my-app --no-interactive', projectDirectory, {});
125+
runCommand(
126+
`npx nx deploy ${nxProjectName} --no-interactive`,
127+
projectDirectory,
128+
{}
129+
);
84130

85131
// ASSERT
86132
// Check that the gh-pages branch exists in the remote
@@ -112,7 +158,7 @@ function createTestProject(remote: string) {
112158
});
113159

114160
execSync(
115-
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive`,
161+
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --skipGit --no-interactive`,
116162
{
117163
cwd: dirname(projectDirectory),
118164
stdio: 'inherit',
@@ -217,6 +263,17 @@ function updateJsonFile<T>(
217263
});
218264
}
219265

266+
function getNxProjectName(
267+
projectDirectory: string,
268+
appName: string
269+
): string {
270+
const pkgJson = JSON.parse(
271+
readFileSync(join(projectDirectory, 'package.json'), 'utf-8')
272+
);
273+
const scopeMatch = (pkgJson.name as string)?.match(/^(@[^/]+)\//);
274+
return scopeMatch ? `${scopeMatch[1]}/${appName}` : appName;
275+
}
276+
220277
function generateReactApp(projectDirectory: string, projectName: string) {
221278
runCommand(
222279
`npx nx g @nx/react:app ${projectName} --directory apps/${projectName} --projectNameAndRootFormat=as-provided --e2eTestRunner none --unitTestRunner none --linter none --no-interactive`,

tools/scripts/start-local-registry.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* It is meant to be called in jest's globalSetup.
44
*/
55
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
6-
import { execFileSync } from 'child_process';
76
import { releasePublish, releaseVersion } from 'nx/release';
87

98
export default async () => {
@@ -24,7 +23,7 @@ export default async () => {
2423
gitCommit: false,
2524
gitTag: false,
2625
firstRelease: true,
27-
generatorOptionsOverrides: {
26+
versionActionsOptionsOverrides: {
2827
skipLockFileUpdate: true,
2928
},
3029
});

0 commit comments

Comments
 (0)