howcode 0.1.6 → 0.1.61

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.
Files changed (2) hide show
  1. package/lib/howcode.js +34 -4
  2. package/package.json +1 -1
package/lib/howcode.js CHANGED
@@ -99,6 +99,26 @@ function getPaths(target, releaseInfo) {
99
99
  }
100
100
  }
101
101
 
102
+ function getAppResourcesPath(installDir, target) {
103
+ if (target.os === 'macos') {
104
+ return path.join(installDir, `${APP_NAME}.app`, 'Contents', 'Resources')
105
+ }
106
+
107
+ return path.join(installDir, APP_NAME, 'resources')
108
+ }
109
+
110
+ function hasPackagedAppBundle(installDir, target) {
111
+ const resourcesPath = getAppResourcesPath(installDir, target)
112
+ return (
113
+ fs.existsSync(path.join(resourcesPath, 'app.asar')) ||
114
+ fs.existsSync(path.join(resourcesPath, 'app', 'package.json'))
115
+ )
116
+ }
117
+
118
+ function isValidInstall(paths, target) {
119
+ return fs.existsSync(paths.executablePath) && hasPackagedAppBundle(paths.installDir, target)
120
+ }
121
+
102
122
  function getWindowsStartMenuShortcutPath() {
103
123
  const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming')
104
124
  return path.join(appData, 'Microsoft', 'Windows', 'Start Menu', 'Programs', `${APP_NAME}.lnk`)
@@ -297,6 +317,10 @@ async function installRelease(target, releaseInfo, paths) {
297
317
  throw new Error(`Downloaded archive did not contain ${target.executable}.`)
298
318
  }
299
319
 
320
+ if (!hasPackagedAppBundle(tempInstallDir, target)) {
321
+ throw new Error('Downloaded archive did not contain the packaged app bundle.')
322
+ }
323
+
300
324
  await fsp.rm(paths.installDir, { recursive: true, force: true })
301
325
  await fsp.rename(tempInstallDir, paths.installDir)
302
326
  await fsp.rm(tempRoot, { recursive: true, force: true })
@@ -369,14 +393,20 @@ async function main() {
369
393
  try {
370
394
  releaseInfo = await resolveLatestRelease(target)
371
395
  } catch (error) {
372
- if (current?.executablePath && fs.existsSync(current.executablePath)) {
373
- await ensureWindowsLaunchIntegration(target, {
396
+ if (current?.executablePath) {
397
+ const currentPaths = {
374
398
  cacheRoot,
375
399
  currentFile: path.join(cacheRoot, 'current.json'),
376
400
  windowsCommandFile: path.join(cacheRoot, `${APP_NAME}.cmd`),
377
401
  installDir: current.installDir || path.dirname(path.dirname(current.executablePath)),
378
402
  launcherWorkingDirectory: path.dirname(current.executablePath),
379
403
  executablePath: current.executablePath,
404
+ }
405
+ if (!isValidInstall(currentPaths, target)) {
406
+ throw error
407
+ }
408
+ await ensureWindowsLaunchIntegration(target, {
409
+ ...currentPaths,
380
410
  })
381
411
  await launch(current.executablePath)
382
412
  return
@@ -386,8 +416,8 @@ async function main() {
386
416
  }
387
417
 
388
418
  const paths = getPaths(target, releaseInfo)
389
- const didInstall = !fs.existsSync(paths.executablePath)
390
- if (!fs.existsSync(paths.executablePath)) {
419
+ const didInstall = !isValidInstall(paths, target)
420
+ if (didInstall) {
391
421
  await installRelease(target, releaseInfo, paths)
392
422
  }
393
423
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "howcode",
3
- "version": "0.1.6",
3
+ "version": "0.1.61",
4
4
  "description": "Desktop coding app for Pi with projects, terminal, git, and diff workflows.",
5
5
  "license": "MIT",
6
6
  "author": "Igor Warzocha",