doc-detective 3.1.0-dev.2 → 3.1.0-dev.3

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.
@@ -46,57 +46,31 @@ jobs:
46
46
  echo "Failed to install doc-detective-core@${{ steps.version.outputs.version }} or doc-detective-common@${{ steps.common_version.outputs.common_version }}"
47
47
  exit 1
48
48
  }
49
- npm audit fix
50
49
 
51
50
  - name: Test the installation
52
51
  run: |
53
52
  npm test
54
53
 
55
- - name: Commit changes
56
- id: commit
54
+ - name: Stage changes
55
+ id: stage
57
56
  run: |
58
57
  git add package.json package-lock.json
59
58
  if git diff --staged --quiet; then
60
59
  echo "No changes to commit"
61
60
  echo "has_changes=false" >> $GITHUB_OUTPUT
62
61
  else
63
- git commit -m "chore: bump doc-detective-core version to ${{ steps.version.outputs.version }}"
64
- git push
65
62
  echo "has_changes=true" >> $GITHUB_OUTPUT
66
63
  fi
67
64
 
68
65
  - name: Bump or sync version
69
66
  id: patch
70
- if: steps.commit.outputs.has_changes == 'true'
67
+ if: steps.stage.outputs.has_changes == 'true'
71
68
  run: |
72
- git checkout -- .
73
- git clean -fd
74
- # Get current project version
75
- PROJ_VERSION=$(node -p "require('./package.json').version")
76
- # Get doc-detective-core version (strip ^ or ~)
77
- CORE_VERSION=$(node -p "(require('./package.json').dependencies['doc-detective-core'] || require('./package.json').devDependencies['doc-detective-core'] || '').replace(/^[^\\d]*/, '')")
78
- # Parse versions
79
- PROJ_MAJOR=$(echo $PROJ_VERSION | cut -d. -f1)
80
- PROJ_MINOR=$(echo $PROJ_VERSION | cut -d. -f2)
81
- core_MAJOR=$(echo $CORE_VERSION | cut -d. -f1)
82
- core_MINOR=$(echo $CORE_VERSION | cut -d. -f2)
83
- if [ "$PROJ_MAJOR" != "$core_MAJOR" ] || [ "$PROJ_MINOR" != "$core_MINOR" ]; then
84
- # Major or minor mismatch: set version to match doc-detective-core major.minor.0
85
- NEW_VERSION="$core_MAJOR.$core_MINOR.0"
86
- npm version --no-git-tag-version "$NEW_VERSION"
87
- else
88
- # Only patch changed: bump patch
89
- npm version patch --no-git-tag-version
90
- fi
91
- git add package.json package-lock.json
92
- git commit -m "bump version to match doc-detective-core"
93
- git push
94
- git tag "v$(node -p \"require('./package.json').version\")"
95
- git push --tags
96
- echo "version=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT
69
+ node scripts/bump-sync-version-core.js
70
+ version=$(node -p 'require("./package.json").version') && echo "version=$version" >> $GITHUB_OUTPUT
97
71
 
98
- - name: Create release
99
- if: steps.commit.outputs.has_changes == 'true'
72
+ - name: Install GitHub CLI
73
+ if: steps.stage.outputs.has_changes == 'true'
100
74
  # Install GitHub CLI for fetching PRs and release notes
101
75
  run: |
102
76
  sudo apt-get update && sudo apt-get install -y gh jq
@@ -120,9 +94,11 @@ jobs:
120
94
  echo "$PRS" >> $GITHUB_OUTPUT
121
95
  echo "EOF" >> $GITHUB_OUTPUT
122
96
  fi
97
+ env:
98
+ GITHUB_TOKEN: ${{ secrets.DD_DEP_UPDATE_TOKEN }}
123
99
 
124
100
  - name: Fetch doc-detective-core release notes
125
- id: core_release
101
+ id: CORE_release
126
102
  run: |
127
103
  CORE_VERSION=${{ steps.version.outputs.version }}
128
104
  # Remove ^ or ~ if present
@@ -132,9 +108,11 @@ jobs:
132
108
  echo "release_notes<<EOF" >> $GITHUB_OUTPUT
133
109
  echo "$RELEASE_INFO" >> $GITHUB_OUTPUT
134
110
  echo "EOF" >> $GITHUB_OUTPUT
111
+ env:
112
+ GITHUB_TOKEN: ${{ secrets.DD_DEP_UPDATE_TOKEN }}
135
113
 
136
114
  - name: Create release with detailed notes
137
- if: steps.commit.outputs.has_changes == 'true'
115
+ if: steps.stage.outputs.has_changes == 'true'
138
116
  uses: softprops/action-gh-release@v2
139
117
  with:
140
118
  body: |
@@ -142,7 +120,7 @@ jobs:
142
120
 
143
121
  - Updated doc-detective-core to v${{ steps.patch.outputs.version }}:
144
122
 
145
- ${{ steps.core_release.outputs.release_notes }}
123
+ ${{ steps.CORE_release.outputs.release_notes }}
146
124
 
147
125
  ${{ steps.merged_prs.outputs.prs }}
148
126
  tag_name: "v${{ steps.patch.outputs.version }}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-detective",
3
- "version": "3.1.0-dev.2",
3
+ "version": "3.1.0-dev.3",
4
4
  "description": "Treat doc content as testable assertions to validate doc accuracy and product UX.",
5
5
  "bin": {
6
6
  "doc-detective": "src/index.js"
@@ -33,8 +33,8 @@
33
33
  "homepage": "https://github.com/doc-detective/doc-detective#readme",
34
34
  "dependencies": {
35
35
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
36
- "doc-detective-common": "^3.1.0-dev.1",
37
- "doc-detective-core": "^3.1.0-dev.2",
36
+ "doc-detective-common": "^3.1.0",
37
+ "doc-detective-core": "^3.1.0",
38
38
  "yargs": "^17.7.2"
39
39
  },
40
40
  "devDependencies": {
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const semver = require("semver");
7
+
8
+ function execCommand(command, options = {}) {
9
+ try {
10
+ return execSync(command, {
11
+ encoding: "utf8",
12
+ stdio: "inherit",
13
+ ...options,
14
+ });
15
+ } catch (error) {
16
+ console.error(`Error executing command: ${command}`);
17
+ process.exit(1);
18
+ }
19
+ }
20
+
21
+ function main() {
22
+ // Clean git state
23
+ execCommand("git checkout -- .");
24
+ execCommand("git clean -fd");
25
+
26
+ // Get current project version
27
+ const packageJsonPath = path.join(process.cwd(), "package.json");
28
+
29
+ if (!fs.existsSync(packageJsonPath)) {
30
+ console.error("Error: package.json not found");
31
+ process.exit(1);
32
+ }
33
+
34
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
35
+ const projVersion = semver.minVersion(packageJson.version);
36
+
37
+ // Get doc-detective-core version
38
+ const coreVersion = semver.minVersion(
39
+ packageJson.dependencies?.["doc-detective-core"] ||
40
+ packageJson.devDependencies?.["doc-detective-core"] ||
41
+ ""
42
+ );
43
+
44
+ if (!coreVersion) {
45
+ console.error("Error: doc-detective-core dependency not found");
46
+ process.exit(1);
47
+ }
48
+
49
+ if (!semver.valid(projVersion)) {
50
+ console.error(`Error: Invalid project version format: ${projVersion}`);
51
+ process.exit(1);
52
+ }
53
+
54
+ // Extract major and minor versions using semver
55
+ const projMajor = semver.major(projVersion);
56
+ const projMinor = semver.minor(projVersion);
57
+ const coreMajor = semver.major(coreVersion);
58
+ const coreMinor = semver.minor(coreVersion);
59
+
60
+ console.log(`Project version: ${projMajor}.${projMinor}.x`);
61
+ console.log(`core version: ${coreMajor}.${coreMinor}.x`);
62
+
63
+ let newVersion;
64
+
65
+ if (projMajor !== coreMajor || projMinor !== coreMinor) {
66
+ // Major or minor mismatch: set version to match doc-detective-core major.minor.0
67
+ newVersion = `${coreMajor}.${coreMinor}.0`;
68
+
69
+ // Validate the new version before setting it
70
+ if (!semver.valid(newVersion)) {
71
+ console.error(`Error: Generated invalid version: ${newVersion}`);
72
+ process.exit(1);
73
+ }
74
+
75
+ console.log(`Version mismatch detected. Setting version to: ${newVersion}`);
76
+ execCommand(`npm version --no-git-tag-version ${newVersion}`);
77
+ } else {
78
+ // Project version is already equal or greater than core version, just bump patch
79
+ console.log("Project version is current or ahead. Bumping patch version.");
80
+ execCommand("npm version patch --no-git-tag-version");
81
+ // Get the new version after bumping
82
+ const updatedPackageJson = JSON.parse(
83
+ fs.readFileSync(packageJsonPath, "utf8")
84
+ );
85
+ newVersion = updatedPackageJson.version;
86
+ }
87
+
88
+ // Commit changes
89
+ execCommand("git add package.json package-lock.json");
90
+ execCommand(
91
+ 'git commit -m "update doc-detective-core [skip ci]"'
92
+ );
93
+
94
+ // Create tag
95
+ execCommand(`git tag "v${newVersion}"`);
96
+
97
+ // Push changes and tags
98
+ execCommand("git push");
99
+ execCommand("git push --tags");
100
+
101
+ // Output version (equivalent to echo in bash script)
102
+ console.log(`version=${newVersion}`);
103
+ }
104
+
105
+ // Run the script
106
+ if (require.main === module) {
107
+ main();
108
+ }
109
+
110
+ module.exports = { main };
package/src/utils.js CHANGED
@@ -117,7 +117,7 @@ async function setConfig({ configPath, args }) {
117
117
  config.logLevel = args.logLevel;
118
118
  }
119
119
  if (typeof args.allowUnsafe === "boolean") {
120
- config.allowUnsafeTests = args.allowUnsafe;
120
+ config.allowUnsafeSteps = args.allowUnsafe;
121
121
  }
122
122
  // Resolve paths
123
123
  config = await resolvePaths({
@@ -169,7 +169,7 @@ describe("Util tests", function () {
169
169
  ],
170
170
  expected: {
171
171
  input: [path.resolve(process.cwd(), "input.spec.json")],
172
- allowUnsafeTests: true,
172
+ allowUnsafeSteps: true,
173
173
  },
174
174
  }
175
175
  ];