MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / buildAndZipTarget

Function buildAndZipTarget

src/build-tools/build-binaries.ts:44–74  ·  view source on GitHub ↗
(target: string)

Source from the content-addressed store, hash-verified

42await writeFile(packFile, code)
43
44const buildAndZipTarget = async (target: string): Promise<void> => {
45 console.log(`Compiling for ${target}:`)
46 const binDir = path.join(distBinDir, target)
47 const binaryFilename = `smartthings${target.startsWith('windows') ? '.exe' : ''}`
48 const fullBinaryFilename = path.join(binDir, binaryFilename)
49 await compile({
50 name: 'smartthings',
51 input: packFile,
52 // nexe's static analysis doesn't always detect the packed entry file as a
53 // dependency to embed (e.g. it misses it when ncc emits require/import shims
54 // for ESM-only transitive dependencies), which leaves the compiled binary
55 // unable to find its own bundled script at runtime. Listing it explicitly
56 // forces nexe to embed it regardless.
57 resources: ['package.json', packFile],
58 remote: 'https://github.com/SmartThingsCommunity/cli-nexe-builds/releases/download/1.0.0',
59 output: fullBinaryFilename,
60 python: 'python3',
61 targets: [`${target}-${nodeVersion}`],
62 })
63
64 console.log(`Compressing ${target}`)
65
66 const [platform, arch] = target.split('-')
67 const archiveExt = platform === 'windows' ? 'zip' : 'tgz'
68
69 const archiveName = path.join(distBinDir, `smartthings-${platform}-${arch}.${archiveExt}`)
70
71 const archive: Archiver = platform === 'windows'
72 ? new ZipArchive({})
73 : new TarArchive({ gzip: true })
74 archive.append(fs.createReadStream(fullBinaryFilename), { name: binaryFilename, mode: 0o755 })
75 archive.pipe(fs.createWriteStream(archiveName))
76
77 return archive.finalize()

Callers 1

build-binaries.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected