Skip to content

Commit 3d1c877

Browse files
authored
feat(replit): install @feathersjs/cli globally and delete upstream tsconfig.json
This commit adds the installation of @feathersjs/cli globally and deletes the upstream tsconfig.json file. Additionally, it updates the Node version used for debugging to v19. This change adds TypeScript debugging with ts-node. To address a dap-node issue with CWD config, a helper script was added which changes the working dir with `--import` the ESM version of `-r`, new to Node v19.
1 parent 1956e4b commit 3d1c877

File tree

2 files changed

+84
-19
lines changed

2 files changed

+84
-19
lines changed

.replit

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1-
hidden=[".config", ".github", ".gitignore", ".prettierrc"]
1+
hidden=[".config", ".github", ".gitignore", ".prettierrc", "quick-start", "react-chat"]
2+
3+
entrypoint = "README.md"
24

3-
# onBoot=["/bin/sh", "-c", "cd feathers-chat-ts"] # Danger, NixOS is weird... node is not in env
45
run = """
6+
cd feathers-chat-ts
7+
npm run dev
8+
""" # """
9+
10+
compile = """
11+
if [ ! -d "feathers-chat-ts/node_modules" ]; then
512
cd feathers-chat-ts
6-
if [ ! -d "node_modules" ]; then
7-
npm i
8-
npm run compile
9-
npm run migrate
10-
fi
11-
npm run dev
12-
"""
13+
npm i
14+
npm i -g @feathersjs/cli
15+
npm run compile
16+
npm run migrate
17+
cd -
18+
fi
1319

14-
entrypoint = "README.md"
20+
# Helper script to deal with lack of CWD support in the Debugger
21+
mkdir -p .config
22+
if [ ! -f "node_modules" ]; then
23+
cat << EOF > ./.config/replit.mjs
24+
// Resolve FEATHERS_DIR path and cd to it
25+
console.log(process.env.NODE_PATH)
26+
if (process.env.FEATHERS_DIR) {
27+
const p = process.env.FEATHERS_DIR
28+
const f = new Function('return \\`' + p + '\\`;').call(process.env)
29+
process.chdir(f)
30+
}
31+
EOF
32+
fi
33+
""" # """
34+
35+
# Runs after `kill 1` or env changes
36+
onBoot = """
37+
rm tsconfig.json 2> /dev/null
38+
""" # """
1539

1640
# Multiple ports
1741
# https://docs.replit.com/programming-ide/configuring-repl#ports
@@ -23,15 +47,14 @@ externalPort = 80
2347
localPort = 9000
2448
externalPort = 9000
2549

26-
2750
[nix]
28-
channel = "stable-22_05"
51+
channel = "stable-22_11"
2952

3053
[env]
31-
EDITOR="vim"
32-
NODE_NO_WARNINGS="1"
3354
PATH = "/home/runner/$REPL_SLUG/.config/npm/node_global/bin:/home/runner/$REPL_SLUG/node_modules/.bin"
55+
EDITOR="replit-git-editor"
3456
npm_config_yes="true"
57+
npm_config_prefix = "/home/runner/$REPL_SLUG/.config/npm/node_global"
3558
HOSTNAME="0.0.0.0"
3659
NODE_OPTIONS="--max_old_space_size=384"
3760

@@ -50,6 +73,50 @@ syntax = "typescript"
5073
[languages.typescript.languageServer]
5174
start = [ "typescript-language-server", "--stdio" ]
5275

53-
# Todo: Default is hard coded to use index.js, without support for TS
5476
[debugger]
55-
support = false
77+
support = true
78+
79+
[debugger.interactive]
80+
transport = "localhost:0"
81+
startCommand = [ "dap-node" ]
82+
83+
[debugger.interactive.initializeMessage]
84+
command = "initialize"
85+
type = "request"
86+
87+
[debugger.interactive.initializeMessage.arguments]
88+
clientID = "replit"
89+
clientName = "replit.com"
90+
columnsStartAt1 = true
91+
linesStartAt1 = true
92+
locale = "en-us"
93+
pathFormat = "path"
94+
supportsInvalidatedEvent = true
95+
supportsProgressReporting = true
96+
supportsRunInTerminalRequest = true
97+
supportsVariablePaging = true
98+
supportsVariableType = true
99+
100+
[debugger.interactive.launchMessage]
101+
command = "launch"
102+
type = "request"
103+
104+
[debugger.interactive.launchMessage.arguments]
105+
runtimeArgs = [
106+
"--import", "./.config/replit.mjs",
107+
"--loader", "./feathers-chat-ts/node_modules/ts-node/esm/transpile-only.mjs"
108+
]
109+
args = []
110+
console = "externalTerminal"
111+
cwd = "."
112+
environment = []
113+
pauseForSourceMap = false
114+
program = "feathers-chat-ts/src/index.ts"
115+
request = "launch"
116+
sourceMaps = true
117+
stopOnEntry = false
118+
type = "pwa-node"
119+
120+
[debugger.interactive.launchMessage.arguments.env]
121+
FEATHERS_DIR = "${this.HOME}/${this.REPL_SLUG}/feathers-chat-ts"
122+

replit.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{ pkgs }: {
22
deps = [
33
pkgs.bashInteractive
4-
pkgs.nodejs-18_x
4+
pkgs.nodejs-19_x
55
pkgs.nodePackages.typescript-language-server
6-
pkgs.vim
7-
pkgs.bind.dnsutils
86
];
97
}

0 commit comments

Comments
 (0)