mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 00:42:45 +08:00
98 lines
2.8 KiB
Ruby
Executable file
Vendored
98 lines
2.8 KiB
Ruby
Executable file
Vendored
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require "webrick"
|
|
|
|
ALLOWED_ARGS = ["-u"]
|
|
EXTRA_ARGS = ARGV - ALLOWED_ARGS
|
|
|
|
if ARGV.include?("-h") || ARGV.include?("--help")
|
|
puts <<~MSG
|
|
bin/ember-cli is deprecated. Use bin/dev instead.
|
|
|
|
Usage (backwards-compatible):
|
|
bin/ember-cli Runs `pnpm start` (frontend only)
|
|
bin/ember-cli -u Runs `bin/dev` (Rails + frontend)
|
|
MSG
|
|
exit 0
|
|
end
|
|
|
|
abort <<~MSG if !EXTRA_ARGS.empty?
|
|
bin/ember-cli no longer accepts arguments: #{EXTRA_ARGS.join(" ")}
|
|
|
|
Discourse now runs from a single port via `bin/dev`. Please switch to:
|
|
bin/dev
|
|
|
|
bin/ember-cli is retained only for backwards compatibility and supports:
|
|
bin/ember-cli (equivalent to `pnpm start`)
|
|
bin/ember-cli -u (equivalent to `bin/dev`)
|
|
MSG
|
|
|
|
child_command, display_command =
|
|
if ARGV.include?("-u")
|
|
[[File.expand_path("dev", __dir__)], "bin/dev"]
|
|
else
|
|
[%w[pnpm start], "pnpm start"]
|
|
end
|
|
|
|
warn "\e[31m[bin/ember-cli] DEPRECATED: please use `bin/dev` instead. Continuing with `#{display_command}`...\e[0m"
|
|
|
|
stub_port = (ENV["EMBER_CLI_STUB_PORT"] || 4200).to_i
|
|
target_port = ENV["UNICORN_PORT"] || "3000"
|
|
|
|
stub_message = <<~MSG
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Ember CLI Removed</title>
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; max-width: 36rem; margin: 4rem auto; padding: 0 1rem; color: #222; line-height: 1.5; }
|
|
h1 { font-size: 1.25rem; margin-bottom: 1rem; }
|
|
code { background: #f3f3f3; padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.95em; }
|
|
a { color: #08c; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Ember CLI has been replaced with Rolldown</h1>
|
|
<p>Discourse is now served from a single port in development. Visit <a href="http://localhost:#{target_port}">http://localhost:#{target_port}</a>.</p>
|
|
<p>To start Rails and the Rolldown build in a single command, use <code>bin/dev</code>.</p>
|
|
<p>To launch a standalone rolldown build, use <code>pnpm start</code>.</p>
|
|
</body>
|
|
</html>
|
|
MSG
|
|
|
|
stub_server =
|
|
begin
|
|
WEBrick::HTTPServer.new(
|
|
Port: stub_port,
|
|
BindAddress: "127.0.0.1",
|
|
Logger: WEBrick::Log.new(File::NULL),
|
|
AccessLog: [],
|
|
)
|
|
rescue Errno::EADDRINUSE
|
|
warn "[bin/ember-cli] Port #{stub_port} already in use; skipping deprecation stub server."
|
|
nil
|
|
end
|
|
|
|
if stub_server
|
|
stub_server.mount_proc "/" do |_req, res|
|
|
res.status = 410
|
|
res["Content-Type"] = "text/html; charset=utf-8"
|
|
res.body = stub_message
|
|
end
|
|
Thread.new { stub_server.start }
|
|
end
|
|
|
|
child_pid = spawn(*child_command)
|
|
|
|
# Children in the foreground process group already receive INT from the terminal;
|
|
# swallow it here so we can clean up the stub server.
|
|
trap("INT") {}
|
|
|
|
begin
|
|
Process.wait(child_pid)
|
|
ensure
|
|
stub_server&.shutdown
|
|
end
|
|
|
|
exit($?.exitstatus || 0)
|