diff --git a/.eslintignore b/.eslintignore index 31d930e..f985219 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ node_modules/ index.js ghjk.ts +.ghjk/ diff --git a/.ghjk/.gitignore b/.ghjk/.gitignore new file mode 100644 index 0000000..abf95c1 --- /dev/null +++ b/.ghjk/.gitignore @@ -0,0 +1,2 @@ +envs +hash.json \ No newline at end of file diff --git a/.ghjk/lock.json b/.ghjk/lock.json new file mode 100644 index 0000000..69e95fd --- /dev/null +++ b/.ghjk/lock.json @@ -0,0 +1,417 @@ +{ + "version": "0", + "platform": "x86_64-linux", + "moduleEntries": { + "ports": { + "version": "0", + "configResolutions": { + "bciqejurda2ofngmfkpobboaj4dztv3pgkd7rz3ppdkbo4ar3kvau3bq": { + "version": "v20.6.0", + "buildDepConfigs": { + "tar_aa": { + "version": "1.34", + "buildDepConfigs": {}, + "portRef": "tar_aa@0.1.0" + } + }, + "portRef": "node_org@0.1.0" + }, + "bciqj4p5hoqweghbuvz52rupja7sqze34z63dd62nz632c5zxikv6ezy": { + "version": "1.34", + "buildDepConfigs": {}, + "portRef": "tar_aa@0.1.0" + }, + "bciqlbtrpnqpzmi5zkmekn6i3v4j52kstg6nmluservmyhyh2f3niqsi": { + "version": "v9.1.0", + "buildDepConfigs": {}, + "portRef": "pnpm_ghrel@0.1.0" + }, + "bciqjlw6cxddajjmznoemlmnu7mgbbm7a3hfmnd2x5oivwajmiqui5ey": { + "version": "v0.2.62", + "buildDepConfigs": {}, + "portRef": "act_ghrel@0.1.0" + } + } + }, + "tasks": { + "version": "0" + }, + "envs": { + "version": "0" + } + }, + "config": { + "modules": [ + { + "id": "ports", + "config": { + "sets": { + "ghjkEnvProvInstSet___main": { + "installs": [ + "bciqd2zqmf5yiorxnjw6wmm45oywzeh76cdq2kt3wm3i4wceu3pmeyya", + "bciqprh64fdx3dpqksmczvqdnlpzldiw337ve7x2aozqhwe6pqlpey3q", + "bciqkmdsvfma4gqsqfchr44f6kx4yqjszbhsfcbcin4fkwpmepplcu2y" + ], + "allowedDeps": "bciqbdwn63lri7vabf6ajy2dzgjlqtdq3zpr2beps7jfdg6s6dps7d5i" + } + } + } + }, + { + "id": "tasks", + "config": { + "envs": {}, + "tasks": {}, + "tasksNamed": [] + } + }, + { + "id": "envs", + "config": { + "envs": { + "main": { + "desc": "the default default environment.", + "provides": [ + { + "ty": "ghjk.ports.InstallSetRef", + "setId": "ghjkEnvProvInstSet___main" + } + ] + } + }, + "defaultEnv": "main" + } + } + ], + "blackboard": { + "bciqd2zqmf5yiorxnjw6wmm45oywzeh76cdq2kt3wm3i4wceu3pmeyya": { + "version": "20.6.0", + "port": { + "ty": "denoWorker@v1", + "name": "node_org", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "buildDeps": [ + { + "name": "tar_aa" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/node.ts" + } + }, + "bciqprh64fdx3dpqksmczvqdnlpzldiw337ve7x2aozqhwe6pqlpey3q": { + "port": { + "ty": "denoWorker@v1", + "name": "pnpm_ghrel", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/pnpm.ts" + } + }, + "bciqkmdsvfma4gqsqfchr44f6kx4yqjszbhsfcbcin4fkwpmepplcu2y": { + "port": { + "ty": "denoWorker@v1", + "name": "act_ghrel", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/act.ts" + } + }, + "bciqb6ua63xodzwxngnbjq35hfikiwzb3dclbqkc7e6xgjdt5jin4pia": { + "manifest": { + "ty": "ambientAccess@v1", + "name": "tar_aa", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin" + ], + "version": "0.1.0", + "execName": "tar", + "versionExtractFlag": "--version", + "versionExtractRegex": "(\\d+\\.\\d+)", + "versionExtractRegexFlags": "" + }, + "defaultInst": { + "portRef": "tar_aa@0.1.0" + } + }, + "bciqfl5s36w335ducrb6f6gwb3vuwup7vzqwwg67pq42xtkngsnxqobi": { + "manifest": { + "ty": "ambientAccess@v1", + "name": "git_aa", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows", + "x86_64-freebsd", + "aarch64-freebsd", + "x86_64-netbsd", + "aarch64-netbsd", + "x86_64-aix", + "aarch64-aix", + "x86_64-solaris", + "aarch64-solaris", + "x86_64-illumos", + "aarch64-illumos", + "x86_64-android", + "aarch64-android" + ], + "version": "0.1.0", + "execName": "git", + "versionExtractFlag": "--version", + "versionExtractRegex": "(\\d+\\.\\d+\\.\\d+)", + "versionExtractRegexFlags": "" + }, + "defaultInst": { + "portRef": "git_aa@0.1.0" + } + }, + "bciqcfe7qyxmokpn6pgtaj35r5qg74jkehuu6cvyrtcsnegvwlm64oqy": { + "manifest": { + "ty": "ambientAccess@v1", + "name": "curl_aa", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows", + "x86_64-freebsd", + "aarch64-freebsd", + "x86_64-netbsd", + "aarch64-netbsd", + "x86_64-aix", + "aarch64-aix", + "x86_64-solaris", + "aarch64-solaris", + "x86_64-illumos", + "aarch64-illumos", + "x86_64-android", + "aarch64-android" + ], + "version": "0.1.0", + "execName": "curl", + "versionExtractFlag": "--version", + "versionExtractRegex": "(\\d+\\.\\d+\\.\\d+)", + "versionExtractRegexFlags": "" + }, + "defaultInst": { + "portRef": "curl_aa@0.1.0" + } + }, + "bciqgkpwxjmo5phw5se4ugyiz4xua3xrd54quzmk7wdwpq3vghglogjy": { + "manifest": { + "ty": "ambientAccess@v1", + "name": "unzip_aa", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "execName": "unzip", + "versionExtractFlag": "-v", + "versionExtractRegex": "(\\d+\\.\\d+)", + "versionExtractRegexFlags": "" + }, + "defaultInst": { + "portRef": "unzip_aa@0.1.0" + } + }, + "bciqmcvyepuficjj3mwshsbfecwdmzch5gwxqo557icnq4zujtdllh4a": { + "manifest": { + "ty": "ambientAccess@v1", + "name": "zstd_aa", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin" + ], + "version": "0.1.0", + "execName": "zstd", + "versionExtractFlag": "--version", + "versionExtractRegex": "v(\\d+\\.\\d+\\.\\d+),", + "versionExtractRegexFlags": "" + }, + "defaultInst": { + "portRef": "zstd_aa@0.1.0" + } + }, + "bciqbus5uksj5zosna6glmp7hnrumqrb4gu7p2nqardqhw43fdlykapi": { + "manifest": { + "ty": "denoWorker@v1", + "name": "rustup_rustlang", + "platforms": [ + "x86_64-darwin", + "aarch64-darwin", + "x86_64-linux", + "aarch64-linux", + "x86_64-windows", + "x86_64-illumos", + "x86_64-freebsd", + "x86_64-netbsd" + ], + "version": "0.1.0", + "buildDeps": [ + { + "name": "git_aa" + } + ], + "resolutionDeps": [ + { + "name": "git_aa" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/rustup.ts" + }, + "defaultInst": { + "portRef": "rustup_rustlang@0.1.0" + } + }, + "bciqg3umt6ba66ft4vkdchvx2ffxlktfo7mq34wxge7iyvlwdazfjkgy": { + "manifest": { + "ty": "denoWorker@v1", + "name": "rust_rustup", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows", + "x86_64-freebsd", + "aarch64-freebsd", + "x86_64-netbsd", + "aarch64-netbsd", + "x86_64-aix", + "aarch64-aix", + "x86_64-solaris", + "aarch64-solaris", + "x86_64-illumos", + "aarch64-illumos", + "x86_64-android", + "aarch64-android" + ], + "version": "0.1.0", + "buildDeps": [ + { + "name": "rustup_rustlang" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/rust.ts" + }, + "defaultInst": { + "portRef": "rust_rustup@0.1.0" + } + }, + "bciqcjdmvoiszcmj5ttpbs75f4vebkqu6rbzjsuyyz4ltq7xahygxzgi": { + "manifest": { + "ty": "denoWorker@v1", + "name": "cargo_binstall_ghrel", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin" + ], + "version": "0.1.0", + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/cargo-binstall.ts" + }, + "defaultInst": { + "portRef": "cargo_binstall_ghrel@0.1.0" + } + }, + "bciqikx65ohapefnex6k2ncw4f722yrxh2o2yswieihkd22metx5r75q": { + "manifest": { + "ty": "denoWorker@v1", + "name": "pnpm_ghrel", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/pnpm.ts" + }, + "defaultInst": { + "portRef": "pnpm_ghrel@0.1.0" + } + }, + "bciqfijmmeplxwqjjcpdf4wwj6hud4qe6ml3hfnpoyw2jb44msw5rzga": { + "manifest": { + "ty": "denoWorker@v1", + "name": "asdf_plugin_git", + "platforms": [ + "aarch64-linux", + "x86_64-linux", + "aarch64-darwin", + "x86_64-darwin", + "aarch64-windows", + "x86_64-windows" + ], + "version": "0.1.0", + "buildDeps": [ + { + "name": "git_aa" + } + ], + "resolutionDeps": [ + { + "name": "git_aa" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/a6dcf8d/ports/asdf_plugin_git.ts" + }, + "defaultInst": { + "portRef": "asdf_plugin_git@0.1.0" + } + }, + "bciqbdwn63lri7vabf6ajy2dzgjlqtdq3zpr2beps7jfdg6s6dps7d5i": { + "tar_aa": "bciqb6ua63xodzwxngnbjq35hfikiwzb3dclbqkc7e6xgjdt5jin4pia", + "git_aa": "bciqfl5s36w335ducrb6f6gwb3vuwup7vzqwwg67pq42xtkngsnxqobi", + "curl_aa": "bciqcfe7qyxmokpn6pgtaj35r5qg74jkehuu6cvyrtcsnegvwlm64oqy", + "unzip_aa": "bciqgkpwxjmo5phw5se4ugyiz4xua3xrd54quzmk7wdwpq3vghglogjy", + "zstd_aa": "bciqmcvyepuficjj3mwshsbfecwdmzch5gwxqo557icnq4zujtdllh4a", + "rustup_rustlang": "bciqbus5uksj5zosna6glmp7hnrumqrb4gu7p2nqardqhw43fdlykapi", + "rust_rustup": "bciqg3umt6ba66ft4vkdchvx2ffxlktfo7mq34wxge7iyvlwdazfjkgy", + "cargo_binstall_ghrel": "bciqcjdmvoiszcmj5ttpbs75f4vebkqu6rbzjsuyyz4ltq7xahygxzgi", + "pnpm_ghrel": "bciqikx65ohapefnex6k2ncw4f722yrxh2o2yswieihkd22metx5r75q", + "asdf_plugin_git": "bciqfijmmeplxwqjjcpdf4wwj6hud4qe6ml3hfnpoyw2jb44msw5rzga" + } + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a2762c..85875aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: Continuous Integration +env: + GHJK_VERSION: 61d9c10 + on: pull_request: push: @@ -22,10 +25,8 @@ jobs: - name: Test Local Action id: test-action uses: ./ - env: - # FIXME: once #14@ghjk lands - GHJK_VERSION: 6040bb3 - name: Check avail of pnpm shell: bash - run: pnpm --version + run: + pnpm --version diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d038e57..524e35e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -37,7 +37,7 @@ jobs: uses: super-linter/super-linter/slim@v5 env: DEFAULT_BRANCH: main - FILTER_REGEX_EXCLUDE: .*\.(js|md) + FILTER_REGEX_EXCLUDE: (.*\.(js|md)|.ghjk*) GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TYPESCRIPT_DEFAULT_STYLE: prettier VALIDATE_ALL_CODEBASE: true diff --git a/.prettierignore b/.prettierignore index fbddacd..658ce45 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ node_modules/ index.js ghjk.ts +.ghjk/ LICENSE diff --git a/README.md b/README.md index baba89e..34561f8 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,18 @@ steps: | `version` | `Ghjk version/ref to use`. | `GHJK_VERSION` or latest GitHub release from ghjk repository. | | `skip-deno-install` | Avoid installing separate deno and use what's found in environment. | `false` | | `installer-url` | Installer script to use. | `https://raw.github.com/metatypedev/ghjk/${version}/install.ts` | -| `sync` | Weather or not to run `ghjk ports sync`. | `true` | +| `cook` | Weather or not to run `ghjk envs cook`. | `true` | | `cache-disable` | Disable caching `$GHJK_DIR/envs`. | `false` | | `cache-save-if` | Weather or not to enable cache saving. Doesn't affect cache restore step. | `true` | | `cache-key-prefix` | Override to add more target entropy to the cache key. | `v0-ghjk` | | `cache-key-env-vars:` | Comma separated list of prefixes to match env var names to. Matches will be hashed into cache key. | "", GHJK and DENO are included by always. | -| Env vars | Desc | Default | -| -------------------------- | -------------------------------------------------------------------------------------------- | ------------------------- | -| `GHJK_DIR` | Root directory for ghjk installation and envs. | `$HOME/.local/share/ghjk` | -| `GHJK_INSTALL_EXE_DIR` | Location to install the `ghjk` exec. | `$HOME/.local/bin` | -| `GHJK_INSTALL_DENO_EXEC` | Alternative deno exec to use. This will not affect weather or not deno is installed as well. | `"deno"` | -| `GHJK_INSTALL_HOOK_SHELLS` | Comma separated list of shells to hook. | `bash` | -| `GHJK_INSTALL_HOOK_MARKER` | Marker to use when installing shell hooks. Hardly relevant in actions. | `ghjk-hook-marker` | -| `GHJK_INSTALL_NO_LOCKFILE` | Hardcode `--no-lock` into the ghjk exec. | `false` | +| Env vars | Desc | Default | +| -------------------------- | -------------------------------------------------------------------------------------------- | -------------------------- | +| `GHJK_ENV` | The environment that'll bee cooked if `cook` is enabled. | Default env from ghjkfile. | +| `GHJK_DIR` | Root directory for ghjk installation and envs. | `$HOME/.local/share/ghjk` | +| `GHJK_INSTALL_EXE_DIR` | Location to install the `ghjk` exec. | `$HOME/.local/bin` | +| `GHJK_INSTALL_DENO_EXEC` | Alternative deno exec to use. This will not affect weather or not deno is installed as well. | `"deno"` | +| `GHJK_INSTALL_HOOK_SHELLS` | Comma separated list of shells to hook. | `bash` | +| `GHJK_INSTALL_HOOK_MARKER` | Marker to use when installing shell hooks. Hardly relevant in actions. | `ghjk-hook-marker` | +| `GHJK_INSTALL_NO_LOCKFILE` | Hardcode `--no-lock` into the ghjk exec. | `false` | diff --git a/action.yml b/action.yml index 28c0b9c..abe0157 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: 'Ghjk everything' -description: 'Installs ghjk, syncs ports, cache ghjk envs' +description: 'Installs ghjk, cooks environment, cache ghjk envs' branding: icon: 'box' color: 'blue' @@ -15,8 +15,8 @@ inputs: installer-url: description: 'Alternative installer script to use' required: false - sync: - description: 'Disable to skip syncing ports' + cook: + description: 'Disable to skip cooking the active environment.' required: true default: true cache-disable: diff --git a/ghjk.ts b/ghjk.ts index 6d913d6..3150a99 100644 --- a/ghjk.ts +++ b/ghjk.ts @@ -1,22 +1,20 @@ -export { ghjk } from "https://raw.github.com/metatypedev/ghjk/6040bb3/mod.ts"; +export { ghjk } from "https://raw.github.com/metatypedev/ghjk/61d9c10/mod.ts"; import { $, install, -} from "https://raw.github.com/metatypedev/ghjk/6040bb3/mod.ts"; -import node from "https://raw.github.com/metatypedev/ghjk/6040bb3/ports/node.ts"; -import pnpm from "https://raw.github.com/metatypedev/ghjk/6040bb3/ports/pnpm.ts"; -import act from "https://raw.github.com/metatypedev/ghjk/6040bb3/ports/act.ts"; +} from "https://raw.github.com/metatypedev/ghjk/61d9c10/mod.ts"; +import * as ports from "https://raw.github.com/metatypedev/ghjk/61d9c10/ports/mod.ts"; install( - node({ - version: "v" + - await $.path(import.meta.resolve("./.node-version")).readText(), + ports.node({ + version: (await $.path(import.meta.resolve("./.node-version")).readText()) + .trim(), }), - pnpm(), + ports.pnpm(), ); if (!Deno.env.has("CI")) { install( - act(), + ports.act(), ); } diff --git a/index.js b/index.js index 145b027..ac18a9c 100644 --- a/index.js +++ b/index.js @@ -81698,10 +81698,11 @@ const cache = __importStar(__nccwpck_require__(7799)); const exec = __importStar(__nccwpck_require__(1514)); const path = __importStar(__nccwpck_require__(1017)); const os = __importStar(__nccwpck_require__(2037)); +const fs = __importStar(__nccwpck_require__(3292)); const node_fetch_1 = __importDefault(__nccwpck_require__(467)); const crypto_1 = __importDefault(__nccwpck_require__(6113)); // TODO: auto-manage these versions -const DENO_VERSION = '1.39.0'; +const DENO_VERSION = '1.42.4'; async function latestGhjkVersion() { const resp = await (0, node_fetch_1.default)(`https://api.github.com/repos/metatypedev/ghjk/releases/latest`); if (!resp.ok) { @@ -81718,12 +81719,16 @@ async function main() { try { const inputVersion = core.getInput('version'); const inputInstallerUrl = core.getInput('installer-url'); - const inputSync = core.getInput('sync'); + const inputCook = core.getInput('cook'); const inputSkipDenoInstall = core.getInput('skip-deno-install'); const inputCacheDisable = core.getInput('cache-disable'); const inputCacheKeyPrefix = core.getInput('cache-key-prefix'); const inputCacheSaveIf = core.getInput('cache-save-if'); const inputCacheKeyEnvVars = core.getInput('cache-key-env-vars'); + process.env.GHJK_LOG = 'debug'; + const denoCache = path.resolve(os.homedir(), '.cache', 'deno'); + process.env.DENO_DIR = denoCache; + process.env.GHJK_INSTALL_DENO_DIR = denoCache; const version = inputVersion.length > 0 ? inputVersion : process.env['GHJK_VERSION'] ?? (await latestGhjkVersion()); @@ -81734,19 +81739,33 @@ async function main() { core.addPath(execDir); const configStr = (await exec.getExecOutput('ghjk', ['print', 'config'])) .stdout; - const ghjkDir = (await exec.getExecOutput('ghjk', ['print', 'ghjk-dir-path'], { + const shareDir = (await exec.getExecOutput('ghjk', ['print', 'share-dir-path'], { silent: true })).stdout.trim(); if (inputCacheDisable === 'false' && cache.isFeatureAvailable()) { const ghjkVersion = (await exec.getExecOutput('ghjk', ['--version'], { silent: true })).stdout.trim(); - const configPath = (await exec.getExecOutput('ghjk', ['print', 'config-path'], { + const configPath = (await exec.getExecOutput('ghjk', ['print', 'ghjkfile-path'], { silent: true })).stdout.trim(); + const ghjkDirPath = (await exec.getExecOutput('ghjk', ['print', 'ghjkfile-path'], { + silent: true + })).stdout.trim(); + const lockfilePath = path.resolve(ghjkDirPath, 'lock.json'); + let lockJson = undefined; + try { + lockJson = await fs.readFile(lockfilePath, { encoding: 'utf8' }); + } + catch (_err) { + /* FILE was not found*/ + } const hasher = crypto_1.default.createHash('sha1'); hasher.update(ghjkVersion); hasher.update(configPath); // TODO: consider ignoring config to avoid misses just for one dep change hasher.update(configStr); + if (lockJson) { + hasher.update(lockJson); + } const hashedEnvs = [ 'GHJK', 'DENO', @@ -81763,9 +81782,9 @@ async function main() { const hash = hasher.digest('hex'); const keyPrefix = inputCacheKeyPrefix.length > 0 ? inputCacheKeyPrefix : 'v0-ghjk'; const key = `${keyPrefix}-${hash}`; - const envsDir = core.toPlatformPath(path.resolve(ghjkDir, 'envs')); - const cacheDirs = [envsDir]; - core.info(JSON.stringify({ cacheDirs, envsDir, ghjkDir })); + const portsDir = core.toPlatformPath(path.resolve(shareDir, 'ports')); + const cacheDirs = [portsDir, denoCache]; + core.info(JSON.stringify({ cacheDirs, portsDir })); // NOTE: restoreCache modifies the array it's given for some reason await cache.restoreCache([...cacheDirs], key); if (inputCacheSaveIf === 'true') { @@ -81777,12 +81796,12 @@ async function main() { }); } } - if (inputSync === 'true') { - await exec.exec('ghjk', ['ports', 'sync']); + if (inputCook === 'true') { + await exec.exec('ghjk', ['envs', 'cook']); } - core.setOutput('GHJK_DIR', ghjkDir); - core.exportVariable('GHJK_DIR', ghjkDir); - core.exportVariable('BASH_ENV', `${ghjkDir}/env.sh`); + core.exportVariable('BASH_ENV', `${shareDir}/env.bash`); + core.exportVariable('GHJK_SHARE_DIR', shareDir); + core.exportVariable('GHJK_DENO_DIR', denoCache); } catch (error) { // Fail the workflow run if an error occurs @@ -81987,6 +82006,14 @@ module.exports = require("fs"); /***/ }), +/***/ 3292: +/***/ ((module) => { + +"use strict"; +module.exports = require("fs/promises"); + +/***/ }), + /***/ 3685: /***/ ((module) => { diff --git a/index.ts b/index.ts index 6775e41..1909c07 100644 --- a/index.ts +++ b/index.ts @@ -4,11 +4,12 @@ import * as cache from '@actions/cache' import * as exec from '@actions/exec' import * as path from 'path' import * as os from 'os' +import * as fs from 'fs/promises' import fetch from 'node-fetch' import crypto from 'crypto' // TODO: auto-manage these versions -const DENO_VERSION = '1.39.0' +const DENO_VERSION = '1.42.4' async function latestGhjkVersion() { const resp = await fetch( @@ -32,13 +33,18 @@ export async function main(): Promise { try { const inputVersion = core.getInput('version') const inputInstallerUrl = core.getInput('installer-url') - const inputSync = core.getInput('sync') + const inputCook = core.getInput('cook') const inputSkipDenoInstall = core.getInput('skip-deno-install') const inputCacheDisable = core.getInput('cache-disable') const inputCacheKeyPrefix = core.getInput('cache-key-prefix') const inputCacheSaveIf = core.getInput('cache-save-if') const inputCacheKeyEnvVars = core.getInput('cache-key-env-vars') + process.env.GHJK_LOG = 'debug' + const denoCache = path.resolve(os.homedir(), '.cache', 'deno') + process.env.DENO_DIR = denoCache + process.env.GHJK_INSTALL_DENO_DIR = denoCache + const version = inputVersion.length > 0 ? inputVersion @@ -60,8 +66,8 @@ export async function main(): Promise { const configStr = (await exec.getExecOutput('ghjk', ['print', 'config'])) .stdout - const ghjkDir = ( - await exec.getExecOutput('ghjk', ['print', 'ghjk-dir-path'], { + const shareDir = ( + await exec.getExecOutput('ghjk', ['print', 'share-dir-path'], { silent: true }) ).stdout.trim() @@ -72,17 +78,33 @@ export async function main(): Promise { ).stdout.trim() const configPath = ( - await exec.getExecOutput('ghjk', ['print', 'config-path'], { + await exec.getExecOutput('ghjk', ['print', 'ghjkfile-path'], { + silent: true + }) + ).stdout.trim() + const ghjkDirPath = ( + await exec.getExecOutput('ghjk', ['print', 'ghjkfile-path'], { silent: true }) ).stdout.trim() + const lockfilePath = path.resolve(ghjkDirPath, 'lock.json') + let lockJson = undefined + try { + lockJson = await fs.readFile(lockfilePath, { encoding: 'utf8' }) + } catch (_err) { + /* FILE was not found*/ + } + const hasher = crypto.createHash('sha1') hasher.update(ghjkVersion) hasher.update(configPath) // TODO: consider ignoring config to avoid misses just for one dep change hasher.update(configStr) + if (lockJson) { + hasher.update(lockJson) + } const hashedEnvs = [ 'GHJK', @@ -102,9 +124,9 @@ export async function main(): Promise { inputCacheKeyPrefix.length > 0 ? inputCacheKeyPrefix : 'v0-ghjk' const key = `${keyPrefix}-${hash}` - const envsDir = core.toPlatformPath(path.resolve(ghjkDir, 'envs')) - const cacheDirs = [envsDir] - core.info(JSON.stringify({ cacheDirs, envsDir, ghjkDir })) + const portsDir = core.toPlatformPath(path.resolve(shareDir, 'ports')) + const cacheDirs = [portsDir, denoCache] + core.info(JSON.stringify({ cacheDirs, portsDir })) // NOTE: restoreCache modifies the array it's given for some reason await cache.restoreCache([...cacheDirs], key) if (inputCacheSaveIf === 'true') { @@ -117,13 +139,13 @@ export async function main(): Promise { } } - if (inputSync === 'true') { - await exec.exec('ghjk', ['ports', 'sync']) + if (inputCook === 'true') { + await exec.exec('ghjk', ['envs', 'cook']) } - core.setOutput('GHJK_DIR', ghjkDir) - core.exportVariable('GHJK_DIR', ghjkDir) - core.exportVariable('BASH_ENV', `${ghjkDir}/env.sh`) + core.exportVariable('BASH_ENV', `${shareDir}/env.bash`) + core.exportVariable('GHJK_SHARE_DIR', shareDir) + core.exportVariable('GHJK_DENO_DIR', denoCache) } catch (error) { // Fail the workflow run if an error occurs if (error instanceof Error) core.setFailed(error.message)