Browse Source

feat: Add cli to nix build

pull/12/head
Dale 1 month ago
parent
commit
8081d50219
Signed by: Deiru GPG Key ID: AA250C0277B927E1
  1. 11
      default.nix
  2. 2
      package.json
  3. 20
      shell.nix
  4. 1
      src/client/UserSettings/ChannelSettingsPage.tsx
  5. 0
      src/client/UserSettings/const.ts
  6. 4
      src/client/hooks/auth.tsx

11
default.nix

@ -37,6 +37,7 @@ in mkYarnPackage rec {
# Build server and client
yarn --offline build:server
yarn --offline build:client
yarn --offline build:cli
runHook postBuild
'';
@ -77,6 +78,16 @@ in mkYarnPackage rec {
--set PATH "$PATH:$node_modules/.bin" \
--set NODE_ENV production
# Copy cli dist
mkdir -p $out/dist/cli
cp -R ./dist/cli/* $out/dist/cli
# Wrap yarn to run control as `miracle-ctl`
makeWrapper $yarnPkg/bin/yarn $out/bin/miracle-ctl \
--add-flags "--cwd $out" \
--add-flags "run:ctl" \
--set NODE_ENV production
runHook preInstall
'';

2
package.json

@ -10,9 +10,11 @@
"daemon:restart": "name=miracle-tv pm2 restart miracle-tv --update-env",
"dev:server": "nodemon -e ts,tsx,graphql --ignore src/shared/theme --ignore src/client --ignore src/pages --exec \"ts-node -r tsconfig-paths/register src/server/server.ts\"",
"run:server": "NODE_ENV=production node dist/server/index.js",
"run:ctl": "NODE_ENV=production node dist/cli/index.js",
"build:server": "ncc build src/server/server.ts -o ./dist/server",
"build:client": "next build",
"build:client:docker": "NODE_ENV=docker next build",
"build:cli": "ncc build src/cli/index.ts -o ./dist/cli",
"run:client": "next start",
"dev:client": "next dev",
"codegen": "graphql-codegen --config codegen.yml",

20
shell.nix

@ -0,0 +1,20 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
miraclePkg = (import ./default.nix);
src = ./.;
in mkShell {
shellHook = ''
export PATH=$PATH:$(pwd)/node_modules/.bin
export node_modules=$(pwd)/node_modules
export API_URL=http://localhost:4000/graphql
yarn
'';
buildInputs = [
miraclePkg.nodePkg miraclePkg.yarnPkg makeWrapper
automake autoconf m4 git bash
libpng libGL gcc yarn2nix
];
}

1
src/client/UserSettings/ChannelSettingsPage.tsx

@ -11,7 +11,6 @@ import { Link } from "miracle-tv-client/components/ui/Link";
import { useRouter } from "next/dist/client/router";
import { head } from "ramda";
import React, { useEffect } from "react";
import { channelFragment } from "miracle-tv-client/UserSettings/const";
import { useUserSettingsChannelQuery } from "miracle-tv-shared/hooks";
import { ChannelEdit } from "./ChannelEdit";
import { ChannelKeysSettings } from "./ChannelKeys";

0
src/client/UserSettings/const.ts

4
src/client/hooks/auth.tsx

@ -19,8 +19,8 @@ type CurrentUserHookReturn = {
};
type CurrentUserSettingsHookReturn = {
isUserLoading: boolean;
isUserCalled: boolean;
isSettingsLoading: boolean;
isSettingsCalled: boolean;
currentSettings: CurrentUserSettings;
};

Loading…
Cancel
Save