diff --git a/.gitignore b/.gitignore index c35014a..732ac9f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /lib/ /marvin/ /marvin-*/ -/node_modules \ No newline at end of file +/node_modules +/result diff --git a/.yarnignore b/.yarnignore new file mode 100644 index 0000000..46bd2dc --- /dev/null +++ b/.yarnignore @@ -0,0 +1,2 @@ +yarn-cache +src/* diff --git a/bin/marvin-timesync.js b/bin/marvin-timesync.js new file mode 100755 index 0000000..1242da5 --- /dev/null +++ b/bin/marvin-timesync.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +import "../lib/index.js" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..353dc71 --- /dev/null +++ b/flake.lock @@ -0,0 +1,45 @@ +{ + "nodes": { + "nix-npm-buildpackage": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677562139, + "narHash": "sha256-J39FdMjECbWGSXVHmEdyGBD2aRYGhg9bWEPf1/ZR47k=", + "owner": "serokell", + "repo": "nix-npm-buildpackage", + "rev": "d45296118cae672982f192451dd3e19fa6c2d068", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "nix-npm-buildpackage", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1673796341, + "narHash": "sha256-1kZi9OkukpNmOaPY7S5/+SlCDOuYnP3HkXHvNDyLQcc=", + "path": "/nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source", + "rev": "6dccdc458512abce8d19f74195bb20fdb067df50", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nix-npm-buildpackage": "nix-npm-buildpackage", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b19807c --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + inputs.nix-npm-buildpackage.url = "github:serokell/nix-npm-buildpackage"; + inputs.nix-npm-buildpackage.inputs.nixpkgs.follows = "nixpkgs"; + outputs = { self, nixpkgs, nix-npm-buildpackage }: { + devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { + buildInputs = with nixpkgs.legacyPackages.x86_64-linux; [ + yarn + nodePackages.typescript-language-server + ]; + }; + packages.x86_64-linux.default = nix-npm-buildpackage.legacyPackages.x86_64-linux.buildYarnPackage { + src = ./.; + postBuild = '' + yarn install --production --ignore-scripts --prefer-offline + ''; + postInstall = "rm $out/bin/yarn"; + meta.mainProgram = "marvin-timesync"; + }; + }; +} diff --git a/package.json b/package.json index 2d0f14e..5cbb5f6 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { - "name": "timesync", + "name": "marvin-timesync", "version": "1.0.0", "main": "index.js", "license": "MIT", "type": "module", + "bin": { + "marvin-timesync": "./bin/marvin-timesync.js" + }, "dependencies": { "@tsconfig/node18": "^1.0.2", "@types/luxon": "^3.3.0", @@ -16,5 +19,12 @@ "pouchdb-find": "^8.0.1", "typescript": "^5.0.4", "xdg-basedir": "^5.1.0" - } + }, + "scripts": { + "watch": "exec tsc --noEmit -w", + "start": "exec tsx ./src/index.ts", + "test": "echo \"Error: no test specified\" && exit 1", + "prepare": "exec tsc" + }, + "private": true }