howcode 0.1.68-dev.0 → 0.1.68
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/lib/howcode.js +51 -3
- package/package.json +3 -3
package/lib/howcode.js
CHANGED
|
@@ -147,6 +147,50 @@ function isValidInstall(paths, target) {
|
|
|
147
147
|
return fs.existsSync(paths.executablePath) && hasPackagedAppBundle(paths.installDir, target)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
function getLinuxCommandLauncherPath() {
|
|
151
|
+
return path.join(process.env.XDG_BIN_HOME || path.join(os.homedir(), '.local', 'bin'), APP_NAME)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function shellSingleQuote(value) {
|
|
155
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function writeLinuxCommandLauncher(paths) {
|
|
159
|
+
const launcherPath = getLinuxCommandLauncherPath()
|
|
160
|
+
const launcherDirectory = path.dirname(launcherPath)
|
|
161
|
+
const launcherContents = [
|
|
162
|
+
'#!/bin/sh',
|
|
163
|
+
`export HOWCODE_REPO_ROOT=${shellSingleQuote(process.env.HOWCODE_REPO_ROOT || process.cwd())}`,
|
|
164
|
+
`exec ${shellSingleQuote(paths.executablePath)} "$@"`,
|
|
165
|
+
'',
|
|
166
|
+
].join('\n')
|
|
167
|
+
|
|
168
|
+
await fsp.mkdir(launcherDirectory, { recursive: true })
|
|
169
|
+
await fsp.writeFile(launcherPath, launcherContents, { encoding: 'utf8', mode: 0o755 })
|
|
170
|
+
await fsp.chmod(launcherPath, 0o755)
|
|
171
|
+
|
|
172
|
+
const pathEntries = (process.env.PATH || '').split(path.delimiter).filter(Boolean)
|
|
173
|
+
if (!pathEntries.includes(launcherDirectory)) {
|
|
174
|
+
console.warn(`${APP_NAME}: created ${launcherPath}, but ${launcherDirectory} is not in PATH.`)
|
|
175
|
+
console.warn(`${APP_NAME}: add it to PATH or relaunch your shell before running ${APP_NAME}.`)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function ensureLinuxLaunchIntegration(target, paths) {
|
|
180
|
+
if (target.os !== 'linux') {
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
await writeLinuxCommandLauncher(paths)
|
|
186
|
+
return true
|
|
187
|
+
} catch (error) {
|
|
188
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
189
|
+
console.warn(`${APP_NAME}: could not create command launcher: ${message}`)
|
|
190
|
+
return false
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
150
194
|
function getWindowsStartMenuShortcutPath() {
|
|
151
195
|
const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming')
|
|
152
196
|
return path.join(appData, 'Microsoft', 'Windows', 'Start Menu', 'Programs', `${APP_NAME}.lnk`)
|
|
@@ -239,7 +283,11 @@ async function createWindowsStartMenuShortcut(paths) {
|
|
|
239
283
|
return shortcutPath
|
|
240
284
|
}
|
|
241
285
|
|
|
242
|
-
async function
|
|
286
|
+
async function ensureCommandLaunchIntegration(target, paths) {
|
|
287
|
+
if (target.os === 'linux') {
|
|
288
|
+
return ensureLinuxLaunchIntegration(target, paths)
|
|
289
|
+
}
|
|
290
|
+
|
|
243
291
|
if (target.os !== 'win') {
|
|
244
292
|
return true
|
|
245
293
|
}
|
|
@@ -523,7 +571,7 @@ async function main() {
|
|
|
523
571
|
if (!isValidInstall(currentPaths, target)) {
|
|
524
572
|
throw error
|
|
525
573
|
}
|
|
526
|
-
await
|
|
574
|
+
await ensureCommandLaunchIntegration(target, {
|
|
527
575
|
...currentPaths,
|
|
528
576
|
})
|
|
529
577
|
await launch(current.executablePath)
|
|
@@ -539,7 +587,7 @@ async function main() {
|
|
|
539
587
|
await installRelease(target, releaseInfo, paths)
|
|
540
588
|
}
|
|
541
589
|
|
|
542
|
-
const launchIntegrationReady = await
|
|
590
|
+
const launchIntegrationReady = await ensureCommandLaunchIntegration(target, paths)
|
|
543
591
|
if (target.os === 'win' && didInstall && launchIntegrationReady) {
|
|
544
592
|
console.log(`${APP_NAME}: installed. You can relaunch it from the Windows Start Menu.`)
|
|
545
593
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "howcode",
|
|
3
|
-
"version": "0.1.68
|
|
3
|
+
"version": "0.1.68",
|
|
4
4
|
"description": "Desktop coding app for Pi with projects, terminal, git, and diff workflows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Igor Warzocha",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"howcode": {
|
|
40
40
|
"appName": "howcode",
|
|
41
|
-
"releaseChannel": "
|
|
42
|
-
"releaseBaseUrl": "https://github.com/IgorWarzocha/howcode/releases/download/channel-
|
|
41
|
+
"releaseChannel": "main",
|
|
42
|
+
"releaseBaseUrl": "https://github.com/IgorWarzocha/howcode/releases/download/channel-main"
|
|
43
43
|
}
|
|
44
44
|
}
|