notion-app: init at 4.2.0
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"x86_64-darwin": {
|
||||
"version": "4.2.0",
|
||||
"url": "https://desktop-release.notion-static.com/Notion-4.2.0.zip",
|
||||
"hash": "sha512-FLptPNEtS9fTevSeGC00hDtpgSks+8JtEKRTtWlYPtI0vpA1KqixBdv2OaNSK1W7Krlsl25RpTOl8cJdQxcv4Q=="
|
||||
},
|
||||
"aarch64-darwin": {
|
||||
"version": "4.2.0",
|
||||
"url": "https://desktop-release.notion-static.com/Notion-arm64-4.2.0.zip",
|
||||
"hash": "sha512-cxfO3Bm7ZzAQMi0Pdwd3nvQlRPjn4w7j0ojYUCcn660YsBtoVkpNhiuqg9pbWzY0Umh+/8Zig9CGXKjjP94Iww=="
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchurl,
|
||||
unzip,
|
||||
}:
|
||||
let
|
||||
info =
|
||||
(builtins.fromJSON (builtins.readFile ./info.json))."${stdenvNoCC.targetPlatform.system}"
|
||||
or (throw "notion-app: unsupported system ${stdenvNoCC.targetPlatform.system}");
|
||||
in
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "notion-app";
|
||||
version = info.version;
|
||||
|
||||
src = fetchurl { inherit (info) url hash; };
|
||||
|
||||
sourceRoot = ".";
|
||||
nativeBuildInputs = [ unzip ];
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/Applications
|
||||
mv Notion.app $out/Applications
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update/update.mjs;
|
||||
|
||||
meta = {
|
||||
description = "App to write, plan, collaborate, and get organised";
|
||||
homepage = "https://www.notion.so/";
|
||||
license = lib.licenses.unfree;
|
||||
maintainers = with lib.maintainers; [ xiaoxiangmoe ];
|
||||
platforms = [
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
};
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"module": "NodeNext",
|
||||
"noEmit": true,
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
/*
|
||||
#!nix-shell -i node --pure --packages cacert nodejs yq-go
|
||||
*/
|
||||
import * as assert from "node:assert/strict";
|
||||
import * as child_process from "node:child_process";
|
||||
import * as fsPromises from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
|
||||
const __dirname = import.meta.dirname;
|
||||
|
||||
/** @typedef {{
|
||||
version: string;
|
||||
path: `${string}.zip`;
|
||||
sha512: string;
|
||||
releaseDate: string;
|
||||
files: Array<{ url: string; sha512: string; size: number }>;
|
||||
}} LiveCheckInfo */
|
||||
|
||||
/** @typedef {{
|
||||
version: string;
|
||||
url: string;
|
||||
hash: `sha512-${string}`;
|
||||
}} Info */
|
||||
|
||||
/** @typedef {{
|
||||
"x86_64-darwin": Info;
|
||||
"aarch64-darwin": Info;
|
||||
}} InfoMap */
|
||||
|
||||
const BASE_URL = "https://desktop-release.notion-static.com/";
|
||||
/**
|
||||
*
|
||||
* @param {"latest-mac.yml" | "arm64-mac.yml"} liveCheckFile
|
||||
* @returns {Promise<Info>}
|
||||
*/
|
||||
async function getInfo(liveCheckFile) {
|
||||
const url = /** @type {const} */ (`${BASE_URL}${liveCheckFile}`);
|
||||
const response = await fetch(url);
|
||||
assert.ok(response.ok, `Failed to fetch ${url}`);
|
||||
/** @type {LiveCheckInfo} */
|
||||
const { version, path, sha512 } = JSON.parse(
|
||||
child_process
|
||||
.execSync(`yq eval --output-format=json`, {
|
||||
input: Buffer.from(await response.arrayBuffer()),
|
||||
})
|
||||
.toString()
|
||||
);
|
||||
assert.ok(version, "version is required");
|
||||
assert.ok(path, "path is required");
|
||||
assert.ok(sha512, "sha512 is required");
|
||||
return {
|
||||
version,
|
||||
url: BASE_URL + path,
|
||||
hash: `sha512-${sha512}`,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const filePath = path.join(__dirname, "../info.json");
|
||||
/** @type {InfoMap} */
|
||||
const oldInfo = JSON.parse(
|
||||
await fsPromises.readFile(filePath, { encoding: "utf-8" })
|
||||
);
|
||||
/** @type {InfoMap} */
|
||||
const info = {
|
||||
"x86_64-darwin": await getInfo("latest-mac.yml"),
|
||||
"aarch64-darwin": await getInfo("arm64-mac.yml"),
|
||||
};
|
||||
if (JSON.stringify(oldInfo) === JSON.stringify(info)) {
|
||||
console.log("[update] No updates found");
|
||||
return;
|
||||
}
|
||||
const platforms = /** @type {const} */ (["x86_64-darwin", "aarch64-darwin"]);
|
||||
for (const platform of platforms) {
|
||||
console.log(
|
||||
`[update] Updating Notion ${platform} ${oldInfo[platform].version} -> ${info[platform].version}`
|
||||
);
|
||||
}
|
||||
await fsPromises.writeFile(
|
||||
filePath,
|
||||
JSON.stringify(info, null, 2) + "\n",
|
||||
"utf-8"
|
||||
);
|
||||
console.log("[update] Updating Notion complete");
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user