capacitor-standard-version 1.1.58 → 1.3.6
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/.github/workflows/build.yml +39 -2
- package/.github/workflows/bump_version.yml +37 -8
- package/.github/workflows/github-releases-to-discord.yml +20 -0
- package/.github/workflows/test.yml +24 -0
- package/CHANGELOG.md +2 -204
- package/bun.lock +153 -439
- package/dist/index.js +9 -2
- package/eslint.config.mjs +5 -9
- package/output.txt +3 -0
- package/package.json +14 -22
- package/src/bin/android.test.ts +166 -0
- package/src/bin/android.ts +24 -9
- package/src/bin/ios.test.ts +159 -0
- package/.eslintignore +0 -2
- package/.husky/pre-commit +0 -4
- package/webpack.config.js +0 -29
package/dist/index.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var w=Object.defineProperty;var j=(E,R)=>{for(var N in R)w(E,N,{get:R[N],enumerable:!0,configurable:!0,set:(I)=>R[N]=()=>I})};import M from"commit-and-tag-version";import Q from"commit-and-tag-version/command";import W from"merge-deep";var l={};j(l,{writeVersion:()=>D,readVersion:()=>z});function O(E){return Number(E.split(".").map((N)=>N.length===1?`0${N}`:N).join(""))}function T(E){if(!E)return 999;let R=Number(E.split(".")[1]||0);if(R>100)throw Error("versionCodeBeta should be less than 100");if(E.startsWith("rc."))R=800+R;else if(E.startsWith("beta."))R=700+R;else if(E.startsWith("alpha."))R=600+R;return R}function _(E,R){return E*1000+R}var U=/versionName( *= *| +)"([^"]*)"\r?\n/g,x=/versionCode( *= *| +)(\d+)\r?\n/g;function z(E){let R=U.exec(E);return U.lastIndex=0,R?R[2]:null}function D(E,R){let[N,I]=R.split("-"),S=E.replace(U,(G,J)=>{let K=G.endsWith(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`;return`versionName${J}"${N}"${K}`}),V=O(N),$=T(I),A=_(V,$);return S.replace(x,(G,J)=>{let K=G.endsWith(`\r
|
|
5
|
+
`)?`\r
|
|
6
|
+
`:`
|
|
7
|
+
`;return`versionCode${J}${A}${K}`})}var f={};j(f,{writeVersion:()=>L,readVersion:()=>H});var p=/MARKETING_VERSION = (.*);\n/g,F=/CURRENT_PROJECT_VERSION = (.*);\n/g;function H(E){let R=E.match(p);return R&&R[0]?R[0].replace(p,"$1"):null}function L(E,R){let[N,I]=R.split("-"),S=E.replace(p,`MARKETING_VERSION = ${N};
|
|
8
|
+
`),V=O(N),$=T(I),A=_(V,$);return S.replace(F,`CURRENT_PROJECT_VERSION = ${A};
|
|
9
|
+
`)}var X={noVerify:!0,tagPrefix:"",packageFiles:[{filename:"./package.json",type:"json"}],bumpFiles:[{filename:"./android/app/build.gradle",updater:l},{filename:"./package.json",type:"json"},{filename:"./package-lock.json",type:"json"},{filename:"./ios/App/App.xcodeproj/project.pbxproj",updater:f}]};async function Y(){try{let E=W(Q.argv,X);await M(E)}catch(E){throw console.error(E),E}}Y();
|
package/eslint.config.mjs
CHANGED
package/output.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"type":"system","subtype":"init","cwd":"/home/runner/work/standard-version-for-capacitor/standard-version-for-capacitor","session_id":"e52ee09e-6889-49d6-8b90-a126c8208268","tools":["Task","Bash","Glob","Grep","LS","ExitPlanMode","Read","Edit","MultiEdit","Write","NotebookEdit","WebFetch","TodoWrite","WebSearch","BashOutput","KillBash"],"mcp_servers":[],"model":"claude-sonnet-4-5-20250929","permissionMode":"default","slash_commands":["add-dir","agents","clear","compact","config","context","cost","doctor","exit","help","ide","init","install-github-app","mcp","memory","migrate-installer","model","output-style","output-style:new","pr-comments","release-notes","resume","status","statusline","bug","review","security-review","upgrade","vim","permissions","hooks","export","logout","login","bashes"],"apiKeySource":"ANTHROPIC_API_KEY","output_style":"default","uuid":"cdd844a3-de16-4e0a-bafa-cb76288354ee"}
|
|
2
|
+
{"type":"assistant","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_01WJ2gmE4H79q9cepebXrJoX","type":"message","role":"assistant","content":[{"type":"text","text":"## Fixed\n\n- Updated package.json repository and homepage URLs to reflect correct GitHub organization"}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2,"cache_creation_input_tokens":10402,"cache_read_input_tokens":4748,"cache_creation":{"ephemeral_5m_input_tokens":10402,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard"}},"parent_tool_use_id":null,"session_id":"e52ee09e-6889-49d6-8b90-a126c8208268","uuid":"70737b63-d337-4168-b099-131478b6e5b8"}
|
|
3
|
+
{"type":"result","subtype":"success","is_error":false,"duration_ms":3098,"duration_api_ms":4381,"num_turns":1,"result":"## Fixed\n\n- Updated package.json repository and homepage URLs to reflect correct GitHub organization","session_id":"e52ee09e-6889-49d6-8b90-a126c8208268","total_cost_usd":0.0410659,"usage":{"input_tokens":2,"cache_creation_input_tokens":10402,"cache_read_input_tokens":4748,"output_tokens":20,"server_tool_use":{"web_search_requests":0},"service_tier":"standard"},"permission_denials":[],"uuid":"e2c2aeb1-90cf-43f8-9280-59daa0c57a20"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-standard-version",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Default standard-version config for capacitor app",
|
|
5
5
|
"author": "Martin Donadieu <martindonadieu@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/Cap-go/
|
|
7
|
+
"homepage": "https://github.com/Cap-go/standard-version-for-capacitor#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/Cap-go/
|
|
10
|
+
"url": "git+https://github.com/Cap-go/standard-version-for-capacitor.git"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/Cap-go/
|
|
13
|
+
"url": "https://github.com/Cap-go/standard-version-for-capacitor/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"capacitor",
|
|
@@ -23,28 +23,20 @@
|
|
|
23
23
|
"capacitor-standard-version": "dist/index.js"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"dev": "
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"lint": "eslint
|
|
30
|
-
"
|
|
26
|
+
"dev": "bun build src/bin/index.ts --outdir dist --target node --packages external",
|
|
27
|
+
"build": "bun build src/bin/index.ts --outdir dist --target node --minify --packages external",
|
|
28
|
+
"lint:fix": "eslint --fix",
|
|
29
|
+
"lint": "eslint",
|
|
30
|
+
"test": "bun test"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"commit-and-tag-version": "^12.
|
|
33
|
+
"commit-and-tag-version": "^12.6.1",
|
|
34
34
|
"merge-deep": "^3.0.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@antfu/eslint-config": "^
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"
|
|
41
|
-
"husky": "^9.1.7",
|
|
42
|
-
"ts-loader": "^9.5.2",
|
|
43
|
-
"ts-node": "^10.9.2",
|
|
44
|
-
"tsconfig-paths": "^4.2.0",
|
|
45
|
-
"typescript": "^5.9.2",
|
|
46
|
-
"webpack": "^5.101.0",
|
|
47
|
-
"webpack-cli": "^6.0.1",
|
|
48
|
-
"webpack-node-externals": "^3.0.0"
|
|
37
|
+
"@antfu/eslint-config": "^6.7.3",
|
|
38
|
+
"@types/bun": "^1.3.5",
|
|
39
|
+
"@types/node": "^25.0.3",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
49
41
|
}
|
|
50
42
|
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { readVersion, writeVersion } from './android'
|
|
3
|
+
|
|
4
|
+
describe('android.ts', () => {
|
|
5
|
+
describe('readVersion', () => {
|
|
6
|
+
it('should read version with space syntax', () => {
|
|
7
|
+
const contents = `
|
|
8
|
+
android {
|
|
9
|
+
defaultConfig {
|
|
10
|
+
versionName "1.2.3"
|
|
11
|
+
versionCode 1002003
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
expect(readVersion(contents)).toBe('1.2.3')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should read version with equals syntax', () => {
|
|
19
|
+
const contents = `
|
|
20
|
+
android {
|
|
21
|
+
defaultConfig {
|
|
22
|
+
versionName = "6.0.1"
|
|
23
|
+
versionCode = 60001999
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
27
|
+
expect(readVersion(contents)).toBe('6.0.1')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should read version with equals and extra spaces', () => {
|
|
31
|
+
const contents = `
|
|
32
|
+
android {
|
|
33
|
+
defaultConfig {
|
|
34
|
+
versionName = "2.0.0"
|
|
35
|
+
versionCode = 2000000
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`
|
|
39
|
+
expect(readVersion(contents)).toBe('2.0.0')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should return null if no version found', () => {
|
|
43
|
+
const contents = `
|
|
44
|
+
android {
|
|
45
|
+
defaultConfig {
|
|
46
|
+
applicationId "com.example.app"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`
|
|
50
|
+
expect(readVersion(contents)).toBeNull()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should handle CRLF line endings', () => {
|
|
54
|
+
const contents = 'android {\r\n defaultConfig {\r\n versionName = "1.0.0"\r\n versionCode = 1000000\r\n }\r\n}\r\n'
|
|
55
|
+
expect(readVersion(contents)).toBe('1.0.0')
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe('writeVersion', () => {
|
|
60
|
+
it('should preserve space syntax for versionName and versionCode', () => {
|
|
61
|
+
const contents = `android {
|
|
62
|
+
defaultConfig {
|
|
63
|
+
versionName "1.0.0"
|
|
64
|
+
versionCode 10000999
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
const result = writeVersion(contents, '2.0.0')
|
|
69
|
+
expect(result).toContain('versionName "2.0.0"')
|
|
70
|
+
// 2.0.0 → 020000 * 1000 + 999 = 20000999
|
|
71
|
+
expect(result).toContain('versionCode 20000999')
|
|
72
|
+
expect(result).not.toContain('versionName =')
|
|
73
|
+
expect(result).not.toContain('versionCode =')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should preserve equals syntax for versionName and versionCode', () => {
|
|
77
|
+
const contents = `android {
|
|
78
|
+
defaultConfig {
|
|
79
|
+
versionName = "6.0.1"
|
|
80
|
+
versionCode = 60001999
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`
|
|
84
|
+
const result = writeVersion(contents, '6.0.2')
|
|
85
|
+
expect(result).toContain('versionName = "6.0.2"')
|
|
86
|
+
// 6.0.2 → 060002 * 1000 + 999 = 60002999
|
|
87
|
+
expect(result).toContain('versionCode = 60002999')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('should preserve equals with spaces syntax', () => {
|
|
91
|
+
const contents = `android {
|
|
92
|
+
defaultConfig {
|
|
93
|
+
versionName = "1.0.0"
|
|
94
|
+
versionCode = 10000999
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
const result = writeVersion(contents, '1.0.1')
|
|
99
|
+
expect(result).toContain('versionName = "1.0.1"')
|
|
100
|
+
// 1.0.1 → 010001 * 1000 + 999 = 10001999
|
|
101
|
+
expect(result).toContain('versionCode = 10001999')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should handle beta versions', () => {
|
|
105
|
+
const contents = `android {
|
|
106
|
+
defaultConfig {
|
|
107
|
+
versionName = "1.0.0"
|
|
108
|
+
versionCode = 10000999
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`
|
|
112
|
+
const result = writeVersion(contents, '1.0.1-beta.1')
|
|
113
|
+
expect(result).toContain('versionName = "1.0.1"')
|
|
114
|
+
// 1.0.1-beta.1 → 010001 * 1000 + 701 = 10001701
|
|
115
|
+
expect(result).toContain('versionCode = 10001701')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('should preserve CRLF line endings', () => {
|
|
119
|
+
const contents = 'android {\r\n defaultConfig {\r\n versionName = "1.0.0"\r\n versionCode = 10000999\r\n }\r\n}\r\n'
|
|
120
|
+
const result = writeVersion(contents, '1.0.1')
|
|
121
|
+
expect(result).toContain('versionName = "1.0.1"\r\n')
|
|
122
|
+
expect(result).toContain('versionCode = 10001999\r\n')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('should preserve LF line endings', () => {
|
|
126
|
+
const contents = 'android {\n defaultConfig {\n versionName = "1.0.0"\n versionCode = 10000999\n }\n}\n'
|
|
127
|
+
const result = writeVersion(contents, '1.0.1')
|
|
128
|
+
expect(result).toContain('versionName = "1.0.1"\n')
|
|
129
|
+
expect(result).toContain('versionCode = 10001999\n')
|
|
130
|
+
expect(result).not.toContain('\r\n')
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('should handle real-world build.gradle content', () => {
|
|
134
|
+
const contents = `plugins {
|
|
135
|
+
id 'com.android.application'
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
android {
|
|
139
|
+
compileSdkVersion 33
|
|
140
|
+
|
|
141
|
+
defaultConfig {
|
|
142
|
+
applicationId "com.example.app"
|
|
143
|
+
minSdkVersion 21
|
|
144
|
+
targetSdkVersion 33
|
|
145
|
+
versionCode = 60001999
|
|
146
|
+
versionName = "6.0.1"
|
|
147
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
buildTypes {
|
|
151
|
+
release {
|
|
152
|
+
minifyEnabled false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`
|
|
157
|
+
const result = writeVersion(contents, '6.0.2')
|
|
158
|
+
// 6.0.2 → 060002 * 1000 + 999 = 60002999
|
|
159
|
+
expect(result).toContain('versionCode = 60002999')
|
|
160
|
+
expect(result).toContain('versionName = "6.0.2"')
|
|
161
|
+
// Ensure other content is preserved
|
|
162
|
+
expect(result).toContain('applicationId "com.example.app"')
|
|
163
|
+
expect(result).toContain('compileSdkVersion 33')
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
})
|
package/src/bin/android.ts
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { versionBetaToCode, versionCodeToCodeBeta, versionPureToCode } from './utils'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
// Regex patterns that match both legacy (space) and modern (equals) Gradle syntax
|
|
4
|
+
// Also handles both Unix (LF) and Windows (CRLF) line endings
|
|
5
|
+
// Captures the full separator (spaces, optional equals, spaces) to preserve formatting
|
|
6
|
+
const regexM = /versionName( *= *| +)"([^"]*)"\r?\n/g
|
|
7
|
+
const regexC = /versionCode( *= *| +)(\d+)\r?\n/g
|
|
8
|
+
|
|
9
|
+
export function readVersion(contents: string): string | null {
|
|
10
|
+
const match = regexM.exec(contents)
|
|
11
|
+
regexM.lastIndex = 0 // Reset regex state for future use
|
|
12
|
+
return match ? match[2] : null
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export function writeVersion(contents, version) {
|
|
15
|
+
export function writeVersion(contents: string, version: string): string {
|
|
12
16
|
const [versionPure, versionBeta] = version.split('-')
|
|
13
|
-
|
|
17
|
+
|
|
18
|
+
// Preserve the original assignment style (space vs equals)
|
|
19
|
+
const newContent = contents.replace(regexM, (match, separator) => {
|
|
20
|
+
const lineEnding = match.endsWith('\r\n') ? '\r\n' : '\n'
|
|
21
|
+
return `versionName${separator}"${versionPure}"${lineEnding}`
|
|
22
|
+
})
|
|
23
|
+
|
|
14
24
|
const versionCode = versionPureToCode(versionPure)
|
|
15
25
|
const versionCodeBeta = versionBetaToCode(versionBeta)
|
|
16
26
|
const versionCodeFinal = versionCodeToCodeBeta(versionCode, versionCodeBeta)
|
|
17
|
-
|
|
27
|
+
|
|
28
|
+
const finalContent = newContent.replace(regexC, (match, separator) => {
|
|
29
|
+
const lineEnding = match.endsWith('\r\n') ? '\r\n' : '\n'
|
|
30
|
+
return `versionCode${separator}${versionCodeFinal}${lineEnding}`
|
|
31
|
+
})
|
|
32
|
+
|
|
18
33
|
return finalContent
|
|
19
34
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { readVersion, writeVersion } from './ios'
|
|
3
|
+
|
|
4
|
+
describe('ios.ts', () => {
|
|
5
|
+
describe('readVersion', () => {
|
|
6
|
+
it('should read MARKETING_VERSION from pbxproj content', () => {
|
|
7
|
+
const contents = `
|
|
8
|
+
/* Begin XCBuildConfiguration section */
|
|
9
|
+
MARKETING_VERSION = 1.2.3;
|
|
10
|
+
CURRENT_PROJECT_VERSION = 10203999;
|
|
11
|
+
/* End XCBuildConfiguration section */
|
|
12
|
+
`
|
|
13
|
+
expect(readVersion(contents)).toBe('1.2.3')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should read version with different formatting', () => {
|
|
17
|
+
const contents = `
|
|
18
|
+
buildSettings = {
|
|
19
|
+
MARKETING_VERSION = 6.0.1;
|
|
20
|
+
CURRENT_PROJECT_VERSION = 60001999;
|
|
21
|
+
};
|
|
22
|
+
`
|
|
23
|
+
expect(readVersion(contents)).toBe('6.0.1')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should return null if no version found', () => {
|
|
27
|
+
const contents = `
|
|
28
|
+
/* Begin XCBuildConfiguration section */
|
|
29
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
30
|
+
/* End XCBuildConfiguration section */
|
|
31
|
+
`
|
|
32
|
+
expect(readVersion(contents)).toBeNull()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should handle multiple MARKETING_VERSION entries (returns first)', () => {
|
|
36
|
+
const contents = `
|
|
37
|
+
/* Debug */
|
|
38
|
+
MARKETING_VERSION = 1.0.0;
|
|
39
|
+
/* Release */
|
|
40
|
+
MARKETING_VERSION = 1.0.0;
|
|
41
|
+
`
|
|
42
|
+
expect(readVersion(contents)).toBe('1.0.0')
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
describe('writeVersion', () => {
|
|
47
|
+
it('should update MARKETING_VERSION and CURRENT_PROJECT_VERSION', () => {
|
|
48
|
+
const contents = `
|
|
49
|
+
buildSettings = {
|
|
50
|
+
MARKETING_VERSION = 1.0.0;
|
|
51
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
52
|
+
};
|
|
53
|
+
`
|
|
54
|
+
const result = writeVersion(contents, '2.0.0')
|
|
55
|
+
expect(result).toContain('MARKETING_VERSION = 2.0.0;')
|
|
56
|
+
// 2.0.0 → 020000 * 1000 + 999 = 20000999
|
|
57
|
+
expect(result).toContain('CURRENT_PROJECT_VERSION = 20000999;')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should handle beta versions', () => {
|
|
61
|
+
const contents = `
|
|
62
|
+
buildSettings = {
|
|
63
|
+
MARKETING_VERSION = 1.0.0;
|
|
64
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
65
|
+
};
|
|
66
|
+
`
|
|
67
|
+
const result = writeVersion(contents, '1.0.1-beta.1')
|
|
68
|
+
expect(result).toContain('MARKETING_VERSION = 1.0.1;')
|
|
69
|
+
// 1.0.1-beta.1 → 010001 * 1000 + 701 = 10001701
|
|
70
|
+
expect(result).toContain('CURRENT_PROJECT_VERSION = 10001701;')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('should handle alpha versions', () => {
|
|
74
|
+
const contents = `
|
|
75
|
+
buildSettings = {
|
|
76
|
+
MARKETING_VERSION = 1.0.0;
|
|
77
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
78
|
+
};
|
|
79
|
+
`
|
|
80
|
+
const result = writeVersion(contents, '1.0.1-alpha.5')
|
|
81
|
+
expect(result).toContain('MARKETING_VERSION = 1.0.1;')
|
|
82
|
+
// 1.0.1-alpha.5 → 010001 * 1000 + 605 = 10001605
|
|
83
|
+
expect(result).toContain('CURRENT_PROJECT_VERSION = 10001605;')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('should handle rc versions', () => {
|
|
87
|
+
const contents = `
|
|
88
|
+
buildSettings = {
|
|
89
|
+
MARKETING_VERSION = 1.0.0;
|
|
90
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
91
|
+
};
|
|
92
|
+
`
|
|
93
|
+
const result = writeVersion(contents, '1.0.1-rc.2')
|
|
94
|
+
expect(result).toContain('MARKETING_VERSION = 1.0.1;')
|
|
95
|
+
// 1.0.1-rc.2 → 010001 * 1000 + 802 = 10001802
|
|
96
|
+
expect(result).toContain('CURRENT_PROJECT_VERSION = 10001802;')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should update multiple occurrences', () => {
|
|
100
|
+
const contents = `
|
|
101
|
+
/* Debug */
|
|
102
|
+
buildSettings = {
|
|
103
|
+
MARKETING_VERSION = 1.0.0;
|
|
104
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
105
|
+
};
|
|
106
|
+
/* Release */
|
|
107
|
+
buildSettings = {
|
|
108
|
+
MARKETING_VERSION = 1.0.0;
|
|
109
|
+
CURRENT_PROJECT_VERSION = 10000999;
|
|
110
|
+
};
|
|
111
|
+
`
|
|
112
|
+
const result = writeVersion(contents, '1.0.1')
|
|
113
|
+
// Should replace all occurrences
|
|
114
|
+
expect(result.match(/MARKETING_VERSION = 1\.0\.1;/g)?.length).toBe(2)
|
|
115
|
+
expect(result.match(/CURRENT_PROJECT_VERSION = 10001999;/g)?.length).toBe(2)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
/* eslint-disable style/no-tabs */
|
|
119
|
+
it('should handle real-world pbxproj content', () => {
|
|
120
|
+
const contents = `// !$*UTF8*$!
|
|
121
|
+
{
|
|
122
|
+
archiveVersion = 1;
|
|
123
|
+
classes = {
|
|
124
|
+
};
|
|
125
|
+
objectVersion = 54;
|
|
126
|
+
objects = {
|
|
127
|
+
/* Begin XCBuildConfiguration section */
|
|
128
|
+
1234567890ABCDEF /* Debug */ = {
|
|
129
|
+
isa = XCBuildConfiguration;
|
|
130
|
+
buildSettings = {
|
|
131
|
+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
|
132
|
+
CODE_SIGN_STYLE = Automatic;
|
|
133
|
+
CURRENT_PROJECT_VERSION = 60001999;
|
|
134
|
+
INFOPLIST_FILE = App/Info.plist;
|
|
135
|
+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
|
136
|
+
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
|
|
137
|
+
MARKETING_VERSION = 6.0.1;
|
|
138
|
+
PRODUCT_BUNDLE_IDENTIFIER = com.example.app;
|
|
139
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
140
|
+
SWIFT_VERSION = 5.0;
|
|
141
|
+
TARGETED_DEVICE_FAMILY = "1,2";
|
|
142
|
+
};
|
|
143
|
+
name = Debug;
|
|
144
|
+
};
|
|
145
|
+
/* End XCBuildConfiguration section */
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
`
|
|
149
|
+
const result = writeVersion(contents, '6.0.2')
|
|
150
|
+
// 6.0.2 → 060002 * 1000 + 999 = 60002999
|
|
151
|
+
expect(result).toContain('CURRENT_PROJECT_VERSION = 60002999;')
|
|
152
|
+
expect(result).toContain('MARKETING_VERSION = 6.0.2;')
|
|
153
|
+
// Ensure other content is preserved
|
|
154
|
+
expect(result).toContain('PRODUCT_BUNDLE_IDENTIFIER = com.example.app;')
|
|
155
|
+
expect(result).toContain('SWIFT_VERSION = 5.0;')
|
|
156
|
+
})
|
|
157
|
+
/* eslint-enable style/no-tabs */
|
|
158
|
+
})
|
|
159
|
+
})
|
package/.eslintignore
DELETED
package/.husky/pre-commit
DELETED
package/webpack.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const webpack = require('webpack');
|
|
3
|
-
const nodeExternals = require('webpack-node-externals');
|
|
4
|
-
console.log(process.env.NODE_ENV || 'production');
|
|
5
|
-
module.exports = {
|
|
6
|
-
mode: process.env.NODE_ENV || 'production',
|
|
7
|
-
target: 'node',
|
|
8
|
-
externals: [nodeExternals()],
|
|
9
|
-
entry: './src/bin/index.ts',
|
|
10
|
-
module: {
|
|
11
|
-
rules: [
|
|
12
|
-
{
|
|
13
|
-
test: /\.ts$/,
|
|
14
|
-
use: 'ts-loader',
|
|
15
|
-
exclude: /node_modules/,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
devtool: process.env.NODE_ENV === 'development' ? 'eval-source-map' : undefined,
|
|
20
|
-
watch: process.env.NODE_ENV === 'development',
|
|
21
|
-
plugins: [new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true })],
|
|
22
|
-
resolve: {
|
|
23
|
-
extensions: ['.ts', '.js'],
|
|
24
|
-
},
|
|
25
|
-
output: {
|
|
26
|
-
filename: 'index.js',
|
|
27
|
-
path: path.resolve(__dirname, 'dist'),
|
|
28
|
-
},
|
|
29
|
-
};
|