cc-pets 0.2.6 → 0.2.8

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/README.md CHANGED
@@ -169,6 +169,9 @@ cc-pets
169
169
  # 前台运行,便于调试
170
170
  cc-pets --foreground
171
171
 
172
+ # 查看当前安装版本(也支持 cc-pets -v)
173
+ cc-pets --version
174
+
172
175
  # 查看当前解析到的 Codex 额度
173
176
  cc-pets --status
174
177
 
@@ -1,6 +1,11 @@
1
1
  #import <Cocoa/Cocoa.h>
2
+
3
+ #ifndef CC_PETS_VERSION
4
+ #define CC_PETS_VERSION "unknown"
5
+ #endif
2
6
  #import <sys/file.h>
3
7
  #import <sys/stat.h>
8
+ #import <fcntl.h>
4
9
  #import <signal.h>
5
10
 
6
11
  static NSString *PetStateDirectory(void) {
@@ -81,14 +86,12 @@ static int RecordHookEvent(void) {
81
86
  return EXIT_SUCCESS;
82
87
  }
83
88
 
84
- static NSDictionary *LatestUsage(void) {
85
- NSString *home = NSProcessInfo.processInfo.environment[@"CODEX_HOME"];
86
- if (home.length == 0) home = [NSHomeDirectory() stringByAppendingPathComponent:@".codex"];
87
- NSURL *sessions = [NSURL fileURLWithPath:[home stringByAppendingPathComponent:@"sessions"]];
89
+ static NSURL *NewestCodexSessionURL(NSURL *directory, BOOL recursive) {
90
+ NSDirectoryEnumerationOptions options = NSDirectoryEnumerationSkipsHiddenFiles;
91
+ if (!recursive) options |= NSDirectoryEnumerationSkipsSubdirectoryDescendants;
88
92
  NSArray *keys = @[NSURLContentModificationDateKey, NSURLIsRegularFileKey];
89
- NSDirectoryEnumerator *files = [NSFileManager.defaultManager enumeratorAtURL:sessions
90
- includingPropertiesForKeys:keys options:NSDirectoryEnumerationSkipsHiddenFiles
91
- errorHandler:nil];
93
+ NSDirectoryEnumerator *files = [NSFileManager.defaultManager enumeratorAtURL:directory
94
+ includingPropertiesForKeys:keys options:options errorHandler:nil];
92
95
  NSURL *newest = nil;
93
96
  NSDate *newestDate = NSDate.distantPast;
94
97
  for (NSURL *url in files) {
@@ -101,6 +104,50 @@ static NSDictionary *LatestUsage(void) {
101
104
  newestDate = date;
102
105
  }
103
106
  }
107
+ return newest;
108
+ }
109
+
110
+ static NSDictionary *UsageFromCodexLine(NSData *lineData) {
111
+ if (lineData.length == 0) return nil;
112
+ NSString *line = [[NSString alloc] initWithData:lineData encoding:NSUTF8StringEncoding];
113
+ if (!line || [line rangeOfString:@"\"type\":\"token_count\""].location == NSNotFound) return nil;
114
+ NSDictionary *root = [NSJSONSerialization JSONObjectWithData:lineData options:0 error:nil];
115
+ NSDictionary *payload = root[@"payload"];
116
+ if (![payload[@"type"] isEqualToString:@"token_count"]) return nil;
117
+ NSDictionary *limits = payload[@"rate_limits"];
118
+ id primaryValue = limits[@"primary"];
119
+ id secondaryValue = limits[@"secondary"];
120
+ NSDictionary *primary = [primaryValue isKindOfClass:NSDictionary.class] ? primaryValue : nil;
121
+ NSDictionary *secondary = [secondaryValue isKindOfClass:NSDictionary.class] ? secondaryValue : nil;
122
+ NSDictionary *fiveHour = nil;
123
+ NSDictionary *week = nil;
124
+ for (NSDictionary *quota in @[primary ?: @{}, secondary ?: @{}]) {
125
+ NSInteger minutes = [quota[@"window_minutes"] integerValue];
126
+ if (minutes == 300) fiveHour = quota;
127
+ if (minutes == 10080) week = quota;
128
+ }
129
+ return @{
130
+ @"fiveHour": fiveHour ?: NSNull.null,
131
+ @"week": week ?: NSNull.null
132
+ };
133
+ }
134
+
135
+ static NSDictionary *LatestUsageInData(NSData *data) {
136
+ NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
137
+ if (!text) return nil;
138
+ NSArray<NSString *> *lines = [text componentsSeparatedByString:@"\n"];
139
+ for (NSString *line in lines.reverseObjectEnumerator) {
140
+ NSDictionary *usage = UsageFromCodexLine([line dataUsingEncoding:NSUTF8StringEncoding]);
141
+ if (usage) return usage;
142
+ }
143
+ return nil;
144
+ }
145
+
146
+ static NSDictionary *LatestUsage(void) {
147
+ NSString *home = NSProcessInfo.processInfo.environment[@"CODEX_HOME"];
148
+ if (home.length == 0) home = [NSHomeDirectory() stringByAppendingPathComponent:@".codex"];
149
+ NSURL *sessions = [NSURL fileURLWithPath:[home stringByAppendingPathComponent:@"sessions"]];
150
+ NSURL *newest = NewestCodexSessionURL(sessions, YES);
104
151
  if (!newest) return nil;
105
152
 
106
153
  NSFileHandle *handle = [NSFileHandle fileHandleForReadingFromURL:newest error:nil];
@@ -109,33 +156,114 @@ static NSDictionary *LatestUsage(void) {
109
156
  [handle seekToFileOffset:size > 2 * 1024 * 1024 ? size - 2 * 1024 * 1024 : 0];
110
157
  NSData *tail = [handle readDataToEndOfFile];
111
158
  [handle closeFile];
112
- NSString *text = [[NSString alloc] initWithData:tail encoding:NSUTF8StringEncoding];
113
- NSArray<NSString *> *lines = [text componentsSeparatedByString:@"\n"];
114
- for (NSString *line in lines.reverseObjectEnumerator) {
115
- if ([line rangeOfString:@"\"type\":\"token_count\""].location == NSNotFound) continue;
116
- NSData *data = [line dataUsingEncoding:NSUTF8StringEncoding];
117
- NSDictionary *root = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
118
- NSDictionary *payload = root[@"payload"];
119
- if (![payload[@"type"] isEqualToString:@"token_count"]) continue;
120
- NSDictionary *limits = payload[@"rate_limits"];
121
- id primaryValue = limits[@"primary"];
122
- id secondaryValue = limits[@"secondary"];
123
- NSDictionary *primary = [primaryValue isKindOfClass:NSDictionary.class] ? primaryValue : nil;
124
- NSDictionary *secondary = [secondaryValue isKindOfClass:NSDictionary.class] ? secondaryValue : nil;
125
- NSDictionary *fiveHour = nil;
126
- NSDictionary *week = nil;
127
- for (NSDictionary *quota in @[primary ?: @{}, secondary ?: @{}]) {
128
- NSInteger minutes = [quota[@"window_minutes"] integerValue];
129
- if (minutes == 300) fiveHour = quota;
130
- if (minutes == 10080) week = quota;
159
+ return LatestUsageInData(tail);
160
+ }
161
+
162
+ @interface CodexUsageReader : NSObject
163
+ @property NSURL *sessionsURL;
164
+ @property NSURL *sessionURL;
165
+ @property NSDictionary *usage;
166
+ @property unsigned long long offset;
167
+ @property NSMutableData *partialLine;
168
+ @property NSTimeInterval lastFullDiscovery;
169
+ - (NSDictionary *)refresh;
170
+ @end
171
+
172
+ @implementation CodexUsageReader
173
+ - (instancetype)init {
174
+ if ((self = [super init])) {
175
+ NSString *home = NSProcessInfo.processInfo.environment[@"CODEX_HOME"];
176
+ if (home.length == 0) home = [NSHomeDirectory() stringByAppendingPathComponent:@".codex"];
177
+ _sessionsURL = [NSURL fileURLWithPath:[home stringByAppendingPathComponent:@"sessions"]];
178
+ _partialLine = [NSMutableData data];
179
+ }
180
+ return self;
181
+ }
182
+ - (void)selectSessionURL:(NSURL *)url {
183
+ self.sessionURL = url;
184
+ self.offset = 0;
185
+ [self.partialLine setLength:0];
186
+ if (!url) {
187
+ self.usage = nil;
188
+ return;
189
+ }
190
+ NSFileHandle *handle = [NSFileHandle fileHandleForReadingFromURL:url error:nil];
191
+ if (!handle) return;
192
+ unsigned long long size = [handle seekToEndOfFile];
193
+ unsigned long long start = size > 2 * 1024 * 1024 ? size - 2 * 1024 * 1024 : 0;
194
+ [handle seekToFileOffset:start];
195
+ NSData *tail = [handle readDataToEndOfFile];
196
+ [handle closeFile];
197
+ self.offset = start + tail.length;
198
+ self.usage = LatestUsageInData(tail);
199
+
200
+ const uint8_t *bytes = tail.bytes;
201
+ NSUInteger lastNewline = NSNotFound;
202
+ for (NSUInteger index = tail.length; index > 0; index--) {
203
+ if (bytes[index - 1] == '\n') {
204
+ lastNewline = index - 1;
205
+ break;
131
206
  }
132
- return @{
133
- @"fiveHour": fiveHour ?: NSNull.null,
134
- @"week": week ?: NSNull.null
135
- };
136
207
  }
137
- return nil;
208
+ if (lastNewline == NSNotFound) [self.partialLine appendData:tail];
209
+ else if (lastNewline + 1 < tail.length) {
210
+ [self.partialLine appendData:[tail subdataWithRange:NSMakeRange(lastNewline + 1, tail.length - lastNewline - 1)]];
211
+ }
212
+ }
213
+ - (void)consumeIncrementalData:(NSData *)data {
214
+ if (data.length == 0) return;
215
+ [self.partialLine appendData:data];
216
+ const uint8_t *bytes = self.partialLine.bytes;
217
+ NSUInteger lineStart = 0;
218
+ for (NSUInteger index = 0; index < self.partialLine.length; index++) {
219
+ if (bytes[index] != '\n') continue;
220
+ NSData *line = [self.partialLine subdataWithRange:NSMakeRange(lineStart, index - lineStart)];
221
+ NSDictionary *newUsage = UsageFromCodexLine(line);
222
+ if (newUsage) self.usage = newUsage;
223
+ lineStart = index + 1;
224
+ }
225
+ if (lineStart > 0) {
226
+ NSData *remainder = [self.partialLine subdataWithRange:
227
+ NSMakeRange(lineStart, self.partialLine.length - lineStart)];
228
+ self.partialLine = [remainder mutableCopy];
229
+ }
230
+ if (self.partialLine.length > 2 * 1024 * 1024) [self.partialLine setLength:0];
138
231
  }
232
+ - (NSDictionary *)refresh {
233
+ NSTimeInterval now = NSDate.date.timeIntervalSince1970;
234
+ BOOL needsFullDiscovery = !self.sessionURL || now - self.lastFullDiscovery >= 60;
235
+ NSURL *candidate = nil;
236
+ if (needsFullDiscovery) {
237
+ candidate = NewestCodexSessionURL(self.sessionsURL, YES);
238
+ self.lastFullDiscovery = now;
239
+ } else {
240
+ candidate = NewestCodexSessionURL(self.sessionURL.URLByDeletingLastPathComponent, NO);
241
+ }
242
+ if (candidate && ![candidate.path isEqualToString:self.sessionURL.path]) [self selectSessionURL:candidate];
243
+ if (!self.sessionURL) return self.usage;
244
+
245
+ NSFileHandle *handle = [NSFileHandle fileHandleForReadingFromURL:self.sessionURL error:nil];
246
+ if (!handle) {
247
+ self.lastFullDiscovery = 0;
248
+ return self.usage;
249
+ }
250
+ unsigned long long size = [handle seekToEndOfFile];
251
+ if (size < self.offset) {
252
+ [handle closeFile];
253
+ [self selectSessionURL:self.sessionURL];
254
+ return self.usage;
255
+ }
256
+ if (size > self.offset) {
257
+ unsigned long long start = self.offset;
258
+ [handle seekToFileOffset:start];
259
+ NSData *newData = [handle readDataToEndOfFile];
260
+ self.offset = start + newData.length;
261
+ [self consumeIncrementalData:newData];
262
+ }
263
+ [handle closeFile];
264
+ return self.usage;
265
+ }
266
+ @end
139
267
 
140
268
  @interface PetView : NSView
141
269
  @property NSImage *sheet;
@@ -720,7 +848,11 @@ static int RenderQuotaDashboard(NSString *path) {
720
848
  @property BOOL petDragging;
721
849
  @property NSString *binaryDirectory;
722
850
  @property PetView *petView;
851
+ @property CodexUsageReader *codexUsageReader;
723
852
  @property unsigned long long agentEventOffset;
853
+ @property NSMutableData *agentEventPartialLine;
854
+ @property dispatch_source_t agentEventSource;
855
+ @property BOOL agentEventReaderInitialized;
724
856
  - (void)showQuotaDashboard;
725
857
  - (void)positionQuotaDashboard;
726
858
  - (void)scheduleQuotaDashboardHide;
@@ -934,6 +1066,8 @@ static int RenderQuotaDashboard(NSString *path) {
934
1066
  NSRect visible = screen.visibleFrame;
935
1067
  [self.panel setFrameOrigin:NSMakePoint(NSMaxX(visible) - size.width - 24, NSMinY(visible) + 18)];
936
1068
  [self.panel orderFrontRegardless];
1069
+ self.codexUsageReader = [CodexUsageReader new];
1070
+ self.agentEventPartialLine = [NSMutableData data];
937
1071
  [self refreshUsage:nil];
938
1072
  if ([NSProcessInfo.processInfo.arguments containsObject:@"--preview-dashboard"]) {
939
1073
  self.pocketHovering = YES;
@@ -942,8 +1076,9 @@ static int RenderQuotaDashboard(NSString *path) {
942
1076
  [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(refreshUsage:) userInfo:nil repeats:YES];
943
1077
  [self refreshClientLifecycle:nil];
944
1078
  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(refreshClientLifecycle:) userInfo:nil repeats:YES];
945
- [self prepareAgentEventReader];
946
- [NSTimer scheduledTimerWithTimeInterval:0.15 target:self selector:@selector(pollAgentEvents:) userInfo:nil repeats:YES];
1079
+ [self startAgentEventReader];
1080
+ [NSTimer scheduledTimerWithTimeInterval:5 target:self
1081
+ selector:@selector(ensureAgentEventReader:) userInfo:nil repeats:YES];
947
1082
  }
948
1083
  - (void)showQuotaDashboard {
949
1084
  [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideQuotaDashboardIfNeeded) object:nil];
@@ -982,6 +1117,15 @@ static int RenderQuotaDashboard(NSString *path) {
982
1117
  NSString *path = AgentEventPath();
983
1118
  NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:path error:nil];
984
1119
  unsigned long long size = [attributes[NSFileSize] unsignedLongLongValue];
1120
+ if (self.agentEventReaderInitialized) {
1121
+ if (size < self.agentEventOffset) {
1122
+ self.agentEventOffset = 0;
1123
+ [self.agentEventPartialLine setLength:0];
1124
+ }
1125
+ [self readNewAgentEvents];
1126
+ return;
1127
+ }
1128
+ self.agentEventReaderInitialized = YES;
985
1129
  self.agentEventOffset = size;
986
1130
  if (size > 0) {
987
1131
  NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
@@ -992,6 +1136,24 @@ static int RenderQuotaDashboard(NSString *path) {
992
1136
  [self processAgentEventData:recent ignoreFirstPartial:start > 0 recentOnly:YES];
993
1137
  }
994
1138
  }
1139
+ - (void)consumeAgentEventData:(NSData *)data {
1140
+ if (data.length == 0) return;
1141
+ [self.agentEventPartialLine appendData:data];
1142
+ const uint8_t *bytes = self.agentEventPartialLine.bytes;
1143
+ NSUInteger lineStart = 0;
1144
+ for (NSUInteger index = 0; index < self.agentEventPartialLine.length; index++) {
1145
+ if (bytes[index] != '\n') continue;
1146
+ NSData *lineData = [self.agentEventPartialLine subdataWithRange:NSMakeRange(lineStart, index - lineStart)];
1147
+ [self processAgentEventData:lineData ignoreFirstPartial:NO recentOnly:NO];
1148
+ lineStart = index + 1;
1149
+ }
1150
+ if (lineStart > 0) {
1151
+ NSData *remainder = [self.agentEventPartialLine subdataWithRange:
1152
+ NSMakeRange(lineStart, self.agentEventPartialLine.length - lineStart)];
1153
+ self.agentEventPartialLine = [remainder mutableCopy];
1154
+ }
1155
+ if (self.agentEventPartialLine.length > 1024 * 1024) [self.agentEventPartialLine setLength:0];
1156
+ }
995
1157
  - (void)processAgentEventData:(NSData *)data ignoreFirstPartial:(BOOL)ignoreFirstPartial recentOnly:(BOOL)recentOnly {
996
1158
  NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
997
1159
  if (!text) return;
@@ -1011,7 +1173,7 @@ static int RenderQuotaDashboard(NSString *path) {
1011
1173
  }
1012
1174
  }
1013
1175
  }
1014
- - (void)pollAgentEvents:(id)sender {
1176
+ - (void)readNewAgentEvents {
1015
1177
  NSString *path = AgentEventPath();
1016
1178
  NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:path error:nil];
1017
1179
  unsigned long long size = [attributes[NSFileSize] unsignedLongLongValue];
@@ -1019,11 +1181,52 @@ static int RenderQuotaDashboard(NSString *path) {
1019
1181
  if (size == self.agentEventOffset) return;
1020
1182
  NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
1021
1183
  if (!handle) return;
1022
- [handle seekToFileOffset:self.agentEventOffset];
1184
+ unsigned long long start = self.agentEventOffset;
1185
+ [handle seekToFileOffset:start];
1023
1186
  NSData *data = [handle readDataToEndOfFile];
1024
1187
  [handle closeFile];
1025
- self.agentEventOffset = size;
1026
- [self processAgentEventData:data ignoreFirstPartial:NO recentOnly:NO];
1188
+ self.agentEventOffset = start + data.length;
1189
+ [self consumeAgentEventData:data];
1190
+ }
1191
+ - (void)startAgentEventReader {
1192
+ if (self.agentEventSource) return;
1193
+ NSString *path = AgentEventPath();
1194
+ [NSFileManager.defaultManager createDirectoryAtPath:path.stringByDeletingLastPathComponent
1195
+ withIntermediateDirectories:YES attributes:nil error:nil];
1196
+ int creator = open(path.fileSystemRepresentation, O_CREAT | O_WRONLY | O_CLOEXEC, S_IRUSR | S_IWUSR);
1197
+ if (creator >= 0) close(creator);
1198
+ int descriptor = open(path.fileSystemRepresentation, O_EVTONLY | O_CLOEXEC);
1199
+ if (descriptor < 0) return;
1200
+ dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, descriptor,
1201
+ DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_DELETE |
1202
+ DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE,
1203
+ dispatch_get_main_queue());
1204
+ if (!source) {
1205
+ close(descriptor);
1206
+ return;
1207
+ }
1208
+ self.agentEventSource = source;
1209
+ __weak typeof(self) weakSelf = self;
1210
+ dispatch_source_set_event_handler(source, ^{
1211
+ typeof(self) strongSelf = weakSelf;
1212
+ if (!strongSelf) return;
1213
+ dispatch_source_t currentSource = strongSelf.agentEventSource;
1214
+ if (!currentSource) return;
1215
+ unsigned long flags = dispatch_source_get_data(currentSource);
1216
+ [strongSelf readNewAgentEvents];
1217
+ if (flags & (DISPATCH_VNODE_DELETE | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE)) {
1218
+ strongSelf.agentEventSource = nil;
1219
+ dispatch_source_cancel(currentSource);
1220
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 * NSEC_PER_MSEC),
1221
+ dispatch_get_main_queue(), ^{ [weakSelf startAgentEventReader]; });
1222
+ }
1223
+ });
1224
+ dispatch_source_set_cancel_handler(source, ^{ close(descriptor); });
1225
+ dispatch_resume(source);
1226
+ [self prepareAgentEventReader];
1227
+ }
1228
+ - (void)ensureAgentEventReader:(id)sender {
1229
+ if (!self.agentEventSource) [self startAgentEventReader];
1027
1230
  }
1028
1231
  - (void)refreshClientLifecycle:(id)sender {
1029
1232
  NSString *clientName = [NSString stringWithFormat:@"cc-pets-%u-clients", getuid()];
@@ -1045,14 +1248,26 @@ static int RenderQuotaDashboard(NSString *path) {
1045
1248
  if (liveClients == 0 && self.managedByCLI) [NSApp terminate:nil];
1046
1249
  }
1047
1250
  - (void)refreshUsage:(id)sender {
1048
- self.quotaView.codexUsage = LatestUsage();
1251
+ self.quotaView.codexUsage = [self.codexUsageReader refresh];
1049
1252
  self.quotaView.claudeUsage = LatestClaudeUsage();
1050
1253
  self.quotaView.needsDisplay = YES;
1051
1254
  }
1255
+ - (void)applicationWillTerminate:(NSNotification *)notification {
1256
+ if (self.agentEventSource) {
1257
+ dispatch_source_cancel(self.agentEventSource);
1258
+ self.agentEventSource = nil;
1259
+ }
1260
+ }
1052
1261
  @end
1053
1262
 
1054
1263
  int main(int argc, const char *argv[]) {
1055
1264
  @autoreleasepool {
1265
+ if (argc > 1 && (strcmp(argv[1], "--version") == 0 ||
1266
+ strcmp(argv[1], "-version") == 0 ||
1267
+ strcmp(argv[1], "-v") == 0)) {
1268
+ printf("cc-pets %s\n", CC_PETS_VERSION);
1269
+ return EXIT_SUCCESS;
1270
+ }
1056
1271
  if (argc > 1 && strcmp(argv[1], "--hook") == 0) return RecordHookEvent();
1057
1272
  if (argc > 1 && strcmp(argv[1], "--claude-usage") == 0) return RecordClaudeUsage();
1058
1273
  if (argc > 2 && strcmp(argv[1], "--render-dashboard") == 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-pets",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "A native macOS desktop pet for Codex CLI and Claude Code",
5
5
  "author": "wangxinyusqn",
6
6
  "license": "MIT",
package/scripts/build.sh CHANGED
@@ -9,12 +9,14 @@ APP_DIR="${BUILD_DIR}/CC Pets.app"
9
9
  APP_MACOS_DIR="${APP_DIR}/Contents/MacOS"
10
10
  APP_RESOURCES_DIR="${APP_DIR}/Contents/Resources"
11
11
  RESOURCE_DIR="${CC_PETS_RESOURCE_DIR:-${PROJECT_DIR}/Sources/CCPets/Resources}"
12
+ PACKAGE_VERSION="$(node -p "require('${PROJECT_DIR}/package.json').version")"
12
13
  mkdir -p "${BUILD_DIR}" "${CACHE_DIR}" "${APP_MACOS_DIR}" "${APP_RESOURCES_DIR}"
13
14
 
14
15
  CLANG_MODULE_CACHE_PATH="${CACHE_DIR}" clang \
15
16
  -fobjc-arc \
16
17
  -fmodules-cache-path="${CACHE_DIR}" \
17
18
  -mmacosx-version-min=13.0 \
19
+ "-DCC_PETS_VERSION=\"${PACKAGE_VERSION}\"" \
18
20
  -framework Cocoa \
19
21
  "${PROJECT_DIR}/Sources/CCPets/main.m" \
20
22
  -o "${BUILD_DIR}/cc-pets"
@@ -30,7 +32,6 @@ fi
30
32
  cp "${BUILD_DIR}/cc-pets" "${APP_MACOS_DIR}/cc-pets"
31
33
  cp "${PROJECT_DIR}/Resources/Info.plist" "${APP_DIR}/Contents/Info.plist"
32
34
  cp "${PROJECT_DIR}/Resources/AppIcon.icns" "${APP_RESOURCES_DIR}/AppIcon.icns"
33
- PACKAGE_VERSION="$(node -p "require('${PROJECT_DIR}/package.json').version")"
34
35
  /usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string ${PACKAGE_VERSION}" "${APP_DIR}/Contents/Info.plist"
35
36
  /usr/libexec/PlistBuddy -c "Add :CFBundleVersion string ${PACKAGE_VERSION}" "${APP_DIR}/Contents/Info.plist"
36
37
  /usr/bin/codesign --force --sign - "${APP_DIR}" >/dev/null