mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
chore: update rush and pnpm versions
This commit is contained in:
parent
bf76ce006f
commit
ef583779fa
23 changed files with 2405 additions and 4591 deletions
24
apps/web/.gitignore
vendored
24
apps/web/.gitignore
vendored
|
@ -1,24 +0,0 @@
|
||||||
|
|
||||||
dist
|
|
||||||
.solid
|
|
||||||
.output
|
|
||||||
.vercel
|
|
||||||
.netlify
|
|
||||||
netlify
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
/node_modules
|
|
||||||
|
|
||||||
# IDEs and editors
|
|
||||||
/.idea
|
|
||||||
.project
|
|
||||||
.classpath
|
|
||||||
*.launch
|
|
||||||
.settings/
|
|
||||||
|
|
||||||
# Temp
|
|
||||||
gitignore
|
|
||||||
|
|
||||||
# System Files
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
|
@ -1,30 +0,0 @@
|
||||||
# SolidStart
|
|
||||||
|
|
||||||
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
|
|
||||||
|
|
||||||
## Creating a project
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# create a new project in the current directory
|
|
||||||
npm init solid@latest
|
|
||||||
|
|
||||||
# create a new project in my-app
|
|
||||||
npm init solid@latest my-app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Developing
|
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
|
|
||||||
|
|
||||||
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.
|
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@yume-chan/tango-web",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "solid-start dev",
|
|
||||||
"build": "solid-start build",
|
|
||||||
"start": "solid-start start"
|
|
||||||
},
|
|
||||||
"type": "module",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^20.2.1",
|
|
||||||
"esbuild": "^0.14.54",
|
|
||||||
"postcss": "^8.4.21",
|
|
||||||
"solid-start-node": "^0.2.19",
|
|
||||||
"typescript": "^5.0.3",
|
|
||||||
"vite": "^4.1.4"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@solidjs/meta": "^0.28.2",
|
|
||||||
"@solidjs/router": "^0.8.2",
|
|
||||||
"@solid-devtools/overlay": "^0.6.0",
|
|
||||||
"@yume-chan/adb": "workspace:^0.0.20",
|
|
||||||
"@yume-chan/adb-credential-web": "workspace:^0.0.20",
|
|
||||||
"@yume-chan/adb-daemon-webusb": "workspace:^0.0.20",
|
|
||||||
"@yume-chan/async": "^2.2.0",
|
|
||||||
"@yume-chan/stream-extra": "workspace:^0.0.20",
|
|
||||||
"@yume-chan/struct": "workspace:^0.0.20",
|
|
||||||
"solid-js": "^1.7.2",
|
|
||||||
"solid-start": "^0.2.26",
|
|
||||||
"undici": "^5.15.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=16.8"
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 664 B |
|
@ -1,64 +0,0 @@
|
||||||
vec2 project(vec2 a, vec2 b) {
|
|
||||||
return a * dot(a, b) / dot(a, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 drawCircle(vec2 coord, vec2 c, float r, float rr, float as, float ae, vec3 color1, vec3 color2) {
|
|
||||||
vec2 delta = coord - c;
|
|
||||||
|
|
||||||
float d = length(delta);
|
|
||||||
if (d < r - 15.0) {
|
|
||||||
return vec4(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
float a = atan(delta.y, delta.x) + 3.14;
|
|
||||||
if (as < ae ? a > as && a < ae : a > as || a < ae) {
|
|
||||||
if (d < r) {
|
|
||||||
return vec4(0, 0, 0, 1);
|
|
||||||
} else if (d < rr) {
|
|
||||||
float crossLength = sqrt(pow(rr, 2.0) * 2.0);
|
|
||||||
float p = length(project(vec2(-1,1),delta)-(vec2(-1,1)*crossLength)) / (crossLength * 2.0);
|
|
||||||
return vec4(mix(color1, color2, p), 1);
|
|
||||||
} else if (d < rr + 15.0) {
|
|
||||||
return vec4(0, 0, 0, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vec4(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 parseColor(int color) {
|
|
||||||
return vec3(float((color >> 16) & 0xff) / 255.0, float((color >> 8) & 0xff) / 255.0, float((color >> 0) & 0xff) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
||||||
{
|
|
||||||
vec2 c1 = vec2(0.6, 0.5) * iResolution.xy;
|
|
||||||
float r1 = 0.3 * iResolution.y;
|
|
||||||
float rr1 = 0.2 * iResolution.y;
|
|
||||||
float as1 = 225.0 / 180.0 * 3.14;
|
|
||||||
float ae1 = 135.0 / 180.0 * 3.14;
|
|
||||||
vec2 c2 = vec2(0.45, 0.5) * iResolution.xy;
|
|
||||||
float r2 = 0.3 * iResolution.y;
|
|
||||||
float rr2 = 0.2 * iResolution.y;
|
|
||||||
float as2 = 315.0 / 180.0 * 3.14;
|
|
||||||
float ae2 = 270.0 / 180.0 * 3.14;
|
|
||||||
float w = 11.0;
|
|
||||||
vec3 color11= parseColor(0xD9D9D9);
|
|
||||||
vec3 color12= parseColor(0x898989);
|
|
||||||
vec3 color21 = parseColor(0x2D6AF6);
|
|
||||||
vec3 color22 = parseColor(0xA3BFFF);
|
|
||||||
|
|
||||||
vec4 color;
|
|
||||||
if (fragCoord.y < iResolution.y / 2.0) {
|
|
||||||
color = drawCircle(fragCoord, c1, rr1, r1, as1, ae1, color11, color12);
|
|
||||||
if (color.a == 0.0) {
|
|
||||||
color = drawCircle(fragCoord, c2, rr2, r2, as2, ae2, color21, color22);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
color = drawCircle(fragCoord, c2, rr2, r2, as2, ae2, color21, color22);
|
|
||||||
if (color.a == 0.0) {
|
|
||||||
color = drawCircle(fragCoord, c1, rr1, r1, as1, ae1, color11, color12);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fragColor = color;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
.increment {
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: inherit;
|
|
||||||
padding: 1em 2em;
|
|
||||||
color: #335d92;
|
|
||||||
background-color: rgba(68, 107, 158, 0.1);
|
|
||||||
border-radius: 2em;
|
|
||||||
border: 2px solid rgba(68, 107, 158, 0);
|
|
||||||
outline: none;
|
|
||||||
width: 200px;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.increment:focus {
|
|
||||||
border: 2px solid #335d92;
|
|
||||||
}
|
|
||||||
|
|
||||||
.increment:active {
|
|
||||||
background-color: rgba(68, 107, 158, 0.2);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { createSignal } from "solid-js";
|
|
||||||
import "./Counter.css";
|
|
||||||
|
|
||||||
export default function Counter() {
|
|
||||||
const [count, setCount] = createSignal(0);
|
|
||||||
return (
|
|
||||||
<button class="increment" onClick={() => setCount(count() + 1)}>
|
|
||||||
Clicks: {count()}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,353 +0,0 @@
|
||||||
import {
|
|
||||||
AdbDaemonTransport,
|
|
||||||
AdbPacketData,
|
|
||||||
AdbPacketInit,
|
|
||||||
AdbSocket,
|
|
||||||
} from "@yume-chan/adb";
|
|
||||||
import AdbWebCredentialStore from "@yume-chan/adb-credential-web";
|
|
||||||
import { PromiseResolver } from "@yume-chan/async";
|
|
||||||
import {
|
|
||||||
Consumable,
|
|
||||||
ConsumableWritableStream,
|
|
||||||
PushReadableStream,
|
|
||||||
PushReadableStreamController,
|
|
||||||
ReadableWritablePair,
|
|
||||||
WritableStream,
|
|
||||||
} from "@yume-chan/stream-extra";
|
|
||||||
|
|
||||||
const CredentialStore = new AdbWebCredentialStore();
|
|
||||||
|
|
||||||
const transports = new Map<string, AdbDaemonTransport>();
|
|
||||||
|
|
||||||
class RetryError extends Error {
|
|
||||||
public constructor() {
|
|
||||||
super("Retry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedWorkerDaemonConnection
|
|
||||||
implements ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>
|
|
||||||
{
|
|
||||||
#serial: string;
|
|
||||||
get serial() {
|
|
||||||
return this.#serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
#port = new PromiseResolver<MessagePort>();
|
|
||||||
|
|
||||||
#readable: PushReadableStream<AdbPacketData>;
|
|
||||||
#readableController!: PushReadableStreamController<AdbPacketData>;
|
|
||||||
get readable() {
|
|
||||||
return this.#readable;
|
|
||||||
}
|
|
||||||
|
|
||||||
#writable: WritableStream<Consumable<AdbPacketInit>>;
|
|
||||||
#writePromise: PromiseResolver<void> | undefined;
|
|
||||||
get writable() {
|
|
||||||
return this.#writable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public constructor(serial: string) {
|
|
||||||
this.#serial = serial;
|
|
||||||
this.#readable = new PushReadableStream((controller) => {
|
|
||||||
this.#readableController = controller;
|
|
||||||
});
|
|
||||||
this.#writable = new WritableStream({
|
|
||||||
write: async (chunk) => {
|
|
||||||
console.log("out begin", chunk);
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
this.#writePromise = new PromiseResolver();
|
|
||||||
const port = await this.#port.promise;
|
|
||||||
console.log("out port", port);
|
|
||||||
port.postMessage({
|
|
||||||
type: "data",
|
|
||||||
payload: chunk.value,
|
|
||||||
});
|
|
||||||
await this.#writePromise.promise;
|
|
||||||
this.#writePromise = undefined;
|
|
||||||
chunk.consume();
|
|
||||||
console.log("out finish");
|
|
||||||
return;
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof RetryError) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public attach(port: MessagePort) {
|
|
||||||
this.#port.resolve(port);
|
|
||||||
port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| { type: "data"; payload: AdbPacketData }
|
|
||||||
| { type: "ack" }
|
|
||||||
| { type: "close" };
|
|
||||||
switch (message.type) {
|
|
||||||
case "data":
|
|
||||||
console.log("in", message.payload);
|
|
||||||
await this.#readableController.enqueue(message.payload);
|
|
||||||
port.postMessage({ type: "ack" });
|
|
||||||
break;
|
|
||||||
case "ack":
|
|
||||||
this.#writePromise!.resolve();
|
|
||||||
break;
|
|
||||||
case "close":
|
|
||||||
this.#readableController.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public detach() {
|
|
||||||
this.#port = new PromiseResolver();
|
|
||||||
this.#writePromise?.reject(new RetryError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedWorkerSocketOwner {
|
|
||||||
#port: MessagePort;
|
|
||||||
|
|
||||||
#socket: AdbSocket;
|
|
||||||
#writer: WritableStreamDefaultWriter<Consumable<Uint8Array>>;
|
|
||||||
#readAbortController = new AbortController();
|
|
||||||
#pendingAck: PromiseResolver<void> | undefined;
|
|
||||||
|
|
||||||
constructor(port: MessagePort, socket: AdbSocket) {
|
|
||||||
this.#port = port;
|
|
||||||
this.#socket = socket;
|
|
||||||
this.#writer = socket.writable.getWriter();
|
|
||||||
|
|
||||||
socket.readable
|
|
||||||
.pipeTo(
|
|
||||||
new WritableStream({
|
|
||||||
write: async (chunk) => {
|
|
||||||
this.#pendingAck = new PromiseResolver();
|
|
||||||
console.log("socket in write", socket.service, chunk);
|
|
||||||
port.postMessage({ type: "data", payload: chunk });
|
|
||||||
await this.#pendingAck.promise;
|
|
||||||
this.#pendingAck = undefined;
|
|
||||||
console.log("socket in write done");
|
|
||||||
},
|
|
||||||
close: () => {
|
|
||||||
console.log("socket in close", socket.service);
|
|
||||||
port.postMessage({ type: "close" });
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
signal: this.#readAbortController.signal,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch((e) => {
|
|
||||||
if (this.#readAbortController.signal.aborted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
|
|
||||||
port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| {
|
|
||||||
type: "data";
|
|
||||||
payload: Uint8Array;
|
|
||||||
}
|
|
||||||
| { type: "ack" }
|
|
||||||
| { type: "close" };
|
|
||||||
switch (message.type) {
|
|
||||||
case "data":
|
|
||||||
await this.write(message.payload);
|
|
||||||
break;
|
|
||||||
case "ack":
|
|
||||||
this.ack();
|
|
||||||
break;
|
|
||||||
case "close":
|
|
||||||
this.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async write(payload: Uint8Array) {
|
|
||||||
await ConsumableWritableStream.write(this.#writer, payload);
|
|
||||||
this.#port.postMessage({ type: "ack" });
|
|
||||||
}
|
|
||||||
|
|
||||||
public ack() {
|
|
||||||
this.#pendingAck!.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
public close() {
|
|
||||||
this.#writer.releaseLock();
|
|
||||||
this.#socket.close();
|
|
||||||
this.#port.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedWorkerTransportOwner {
|
|
||||||
#port: MessagePort;
|
|
||||||
|
|
||||||
#transport: AdbDaemonTransport;
|
|
||||||
|
|
||||||
constructor(port: MessagePort, transport: AdbDaemonTransport) {
|
|
||||||
this.#port = port;
|
|
||||||
this.#transport = transport;
|
|
||||||
|
|
||||||
transport.disconnected.then(() => {
|
|
||||||
port.postMessage({ type: "close" });
|
|
||||||
});
|
|
||||||
|
|
||||||
port.onmessage = async (event) => {
|
|
||||||
const message = event.data as {
|
|
||||||
type: "connect";
|
|
||||||
id: number;
|
|
||||||
service: string;
|
|
||||||
};
|
|
||||||
switch (message.type) {
|
|
||||||
case "connect":
|
|
||||||
await this.connect(message.id, message.service);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async connect(id: number, service: string) {
|
|
||||||
try {
|
|
||||||
const socket = await this.#transport.connect(service);
|
|
||||||
const channel = new MessageChannel();
|
|
||||||
const server = new SharedWorkerSocketOwner(channel.port2, socket);
|
|
||||||
this.#port.postMessage(
|
|
||||||
{
|
|
||||||
type: "connect",
|
|
||||||
id: id,
|
|
||||||
result: true,
|
|
||||||
port: channel.port1,
|
|
||||||
},
|
|
||||||
[channel.port1]
|
|
||||||
);
|
|
||||||
} catch {
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "connect",
|
|
||||||
id: id,
|
|
||||||
result: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare interface SharedWorkerGlobalScope {
|
|
||||||
onconnect: (e: MessageEvent) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const clientToConnections = new Map<
|
|
||||||
MessagePort,
|
|
||||||
Set<SharedWorkerDaemonConnection>
|
|
||||||
>();
|
|
||||||
const serialToConnection = new Map<string, SharedWorkerDaemonConnection>();
|
|
||||||
|
|
||||||
async function connect(port: MessagePort, serial: string) {
|
|
||||||
const channel = new MessageChannel();
|
|
||||||
|
|
||||||
const messageResolver = new PromiseResolver<{
|
|
||||||
type: "connect";
|
|
||||||
result: boolean;
|
|
||||||
}>();
|
|
||||||
channel.port2.onmessage = async (event) => {
|
|
||||||
messageResolver.resolve(event.data);
|
|
||||||
};
|
|
||||||
|
|
||||||
port.postMessage({ type: "connect", serial, port: channel.port1 }, [
|
|
||||||
channel.port1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const message = await messageResolver.promise;
|
|
||||||
switch (message.type) {
|
|
||||||
case "connect":
|
|
||||||
if (!message.result) {
|
|
||||||
throw new Error("Failed to connect");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serialToConnection.has(serial)) {
|
|
||||||
const connection = serialToConnection.get(serial)!;
|
|
||||||
console.log("switch", connection, "to", port);
|
|
||||||
connection.attach(channel.port2);
|
|
||||||
clientToConnections.get(port)!.add(connection);
|
|
||||||
} else {
|
|
||||||
const connection = new SharedWorkerDaemonConnection(serial);
|
|
||||||
connection.attach(channel.port2);
|
|
||||||
serialToConnection.set(serial, connection);
|
|
||||||
clientToConnections.get(port)!.add(connection);
|
|
||||||
|
|
||||||
const transport = await AdbDaemonTransport.authenticate({
|
|
||||||
serial,
|
|
||||||
connection,
|
|
||||||
credentialStore: CredentialStore,
|
|
||||||
});
|
|
||||||
transports.set(transport.serial, transport);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Unknown message type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(globalThis as unknown as SharedWorkerGlobalScope).onconnect = (e) => {
|
|
||||||
const port = e.ports[0]!;
|
|
||||||
clientToConnections.set(port, new Set());
|
|
||||||
|
|
||||||
port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| {
|
|
||||||
type: "query";
|
|
||||||
id: number;
|
|
||||||
serial: string;
|
|
||||||
}
|
|
||||||
| { type: "disconnect" };
|
|
||||||
switch (message.type) {
|
|
||||||
case "query":
|
|
||||||
if (!transports.has(message.serial)) {
|
|
||||||
await connect(port, message.serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
const transport = transports.get(message.serial)!;
|
|
||||||
const channel = new MessageChannel();
|
|
||||||
port.postMessage(
|
|
||||||
{
|
|
||||||
type: "query-success",
|
|
||||||
id: message.id,
|
|
||||||
serial: message.serial,
|
|
||||||
product: transport.banner.product,
|
|
||||||
model: transport.banner.model,
|
|
||||||
device: transport.banner.device,
|
|
||||||
features: transport.banner.features,
|
|
||||||
maxPayloadSize: transport.maxPayloadSize,
|
|
||||||
port: channel.port1,
|
|
||||||
},
|
|
||||||
[channel.port1]
|
|
||||||
);
|
|
||||||
new SharedWorkerTransportOwner(channel.port2, transport);
|
|
||||||
break;
|
|
||||||
case "disconnect":
|
|
||||||
for (const connection of clientToConnections.get(port)!) {
|
|
||||||
connection.detach();
|
|
||||||
}
|
|
||||||
let nextClient: MessagePort;
|
|
||||||
for (const client of clientToConnections.keys()) {
|
|
||||||
if (client !== port) {
|
|
||||||
nextClient = client;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Promise.all(
|
|
||||||
Array.from(clientToConnections.get(port)!, (connection) =>
|
|
||||||
connect(nextClient, connection.serial)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
clientToConnections.delete(port);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,3 +0,0 @@
|
||||||
import { mount, StartClient } from "solid-start/entry-client";
|
|
||||||
|
|
||||||
mount(() => <StartClient />, document);
|
|
|
@ -1,9 +0,0 @@
|
||||||
import {
|
|
||||||
createHandler,
|
|
||||||
renderAsync,
|
|
||||||
StartServer,
|
|
||||||
} from "solid-start/entry-server";
|
|
||||||
|
|
||||||
export default createHandler(
|
|
||||||
renderAsync((event) => <StartServer event={event} />)
|
|
||||||
);
|
|
|
@ -1,40 +0,0 @@
|
||||||
body {
|
|
||||||
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
|
|
||||||
"Helvetica Neue", sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
text-align: center;
|
|
||||||
padding: 1em;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
color: #335d92;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 4rem;
|
|
||||||
font-weight: 100;
|
|
||||||
line-height: 1.1;
|
|
||||||
margin: 4rem auto;
|
|
||||||
max-width: 14rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
max-width: 14rem;
|
|
||||||
margin: 2rem auto;
|
|
||||||
line-height: 1.35;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 480px) {
|
|
||||||
h1 {
|
|
||||||
max-width: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
max-width: none;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
// @refresh reload
|
|
||||||
import { Suspense } from "solid-js";
|
|
||||||
import {
|
|
||||||
A,
|
|
||||||
Body,
|
|
||||||
ErrorBoundary,
|
|
||||||
FileRoutes,
|
|
||||||
Head,
|
|
||||||
Html,
|
|
||||||
Meta,
|
|
||||||
Routes,
|
|
||||||
Scripts,
|
|
||||||
Title,
|
|
||||||
} from "solid-start";
|
|
||||||
import "./root.css";
|
|
||||||
|
|
||||||
export default function Root() {
|
|
||||||
return (
|
|
||||||
<Html lang="en">
|
|
||||||
<Head>
|
|
||||||
<Title>SolidStart - Bare</Title>
|
|
||||||
<Meta charset="utf-8" />
|
|
||||||
<Meta
|
|
||||||
name="viewport"
|
|
||||||
content="width=device-width, initial-scale=1"
|
|
||||||
/>
|
|
||||||
</Head>
|
|
||||||
<Body>
|
|
||||||
<Suspense>
|
|
||||||
<ErrorBoundary>
|
|
||||||
<A href="/">Index</A>
|
|
||||||
<A href="/about">About</A>
|
|
||||||
<Routes>
|
|
||||||
<FileRoutes />
|
|
||||||
</Routes>
|
|
||||||
</ErrorBoundary>
|
|
||||||
</Suspense>
|
|
||||||
<Scripts />
|
|
||||||
</Body>
|
|
||||||
</Html>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { Title } from "solid-start";
|
|
||||||
import { HttpStatusCode } from "solid-start/server";
|
|
||||||
|
|
||||||
export default function NotFound() {
|
|
||||||
return (
|
|
||||||
<main>
|
|
||||||
<Title>Not Found</Title>
|
|
||||||
<HttpStatusCode code={404} />
|
|
||||||
<h1>Page Not Found</h1>
|
|
||||||
<p>
|
|
||||||
Visit{" "}
|
|
||||||
<a href="https://start.solidjs.com" target="_blank">
|
|
||||||
start.solidjs.com
|
|
||||||
</a>{" "}
|
|
||||||
to learn how to build SolidStart apps.
|
|
||||||
</p>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,441 +0,0 @@
|
||||||
import {
|
|
||||||
Adb,
|
|
||||||
AdbBanner,
|
|
||||||
AdbFeature,
|
|
||||||
AdbIncomingSocketHandler,
|
|
||||||
AdbPacketData,
|
|
||||||
AdbPacketInit,
|
|
||||||
AdbSocket,
|
|
||||||
AdbTransport,
|
|
||||||
} from "@yume-chan/adb";
|
|
||||||
import {
|
|
||||||
ADB_DEFAULT_DEVICE_FILTER,
|
|
||||||
AdbDaemonWebUsbDeviceManager,
|
|
||||||
} from "@yume-chan/adb-daemon-webusb";
|
|
||||||
import { AsyncOperationManager, PromiseResolver } from "@yume-chan/async";
|
|
||||||
import {
|
|
||||||
Consumable,
|
|
||||||
ConsumableWritableStream,
|
|
||||||
PushReadableStream,
|
|
||||||
PushReadableStreamController,
|
|
||||||
WritableStream,
|
|
||||||
} from "@yume-chan/stream-extra";
|
|
||||||
import { createSignal } from "solid-js";
|
|
||||||
import { Title } from "solid-start";
|
|
||||||
|
|
||||||
class SharedWorkerSocket implements AdbSocket {
|
|
||||||
#port: MessagePort;
|
|
||||||
|
|
||||||
#service: string;
|
|
||||||
get service() {
|
|
||||||
return this.#service;
|
|
||||||
}
|
|
||||||
|
|
||||||
#readable: PushReadableStream<Uint8Array>;
|
|
||||||
#readableController!: PushReadableStreamController<Uint8Array>;
|
|
||||||
get readable() {
|
|
||||||
return this.#readable;
|
|
||||||
}
|
|
||||||
|
|
||||||
#writable: WritableStream<Consumable<Uint8Array>>;
|
|
||||||
#pendingWrite: PromiseResolver<void> | undefined;
|
|
||||||
get writable() {
|
|
||||||
return this.#writable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public constructor(port: MessagePort, service: string) {
|
|
||||||
this.#port = port;
|
|
||||||
this.#service = service;
|
|
||||||
|
|
||||||
this.#readable = new PushReadableStream((controller) => {
|
|
||||||
this.#readableController = controller;
|
|
||||||
});
|
|
||||||
this.#writable = new WritableStream({
|
|
||||||
write: async (chunk) => {
|
|
||||||
this.#pendingWrite = new PromiseResolver();
|
|
||||||
port.postMessage({
|
|
||||||
type: "data",
|
|
||||||
payload: chunk.value,
|
|
||||||
});
|
|
||||||
await this.#pendingWrite.promise;
|
|
||||||
this.#pendingWrite = undefined;
|
|
||||||
chunk.consume();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
this.#port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| {
|
|
||||||
type: "data";
|
|
||||||
payload: Uint8Array;
|
|
||||||
}
|
|
||||||
| { type: "ack" }
|
|
||||||
| { type: "close" };
|
|
||||||
switch (message.type) {
|
|
||||||
case "data":
|
|
||||||
console.log("socket in", this.#service, message.payload);
|
|
||||||
await this.#readableController.enqueue(message.payload);
|
|
||||||
port.postMessage({ type: "ack" });
|
|
||||||
break;
|
|
||||||
case "ack":
|
|
||||||
this.#pendingWrite!.resolve();
|
|
||||||
break;
|
|
||||||
case "close":
|
|
||||||
this.#readableController.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public close() {
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "close",
|
|
||||||
});
|
|
||||||
this.#port.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedWorkerTransport implements AdbTransport {
|
|
||||||
#serial: string;
|
|
||||||
get serial() {
|
|
||||||
return this.#serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
#maxPayloadSize: number;
|
|
||||||
get maxPayloadSize() {
|
|
||||||
return this.#maxPayloadSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
#banner: AdbBanner;
|
|
||||||
get banner() {
|
|
||||||
return this.#banner;
|
|
||||||
}
|
|
||||||
|
|
||||||
#port: MessagePort;
|
|
||||||
#operations = new AsyncOperationManager();
|
|
||||||
|
|
||||||
#reverseTunnels = new Map<string, AdbIncomingSocketHandler>();
|
|
||||||
|
|
||||||
#disconnected = new PromiseResolver<void>();
|
|
||||||
get disconnected() {
|
|
||||||
return this.#disconnected.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
public constructor(
|
|
||||||
serial: string,
|
|
||||||
maxPayloadSize: number,
|
|
||||||
banner: AdbBanner,
|
|
||||||
port: MessagePort
|
|
||||||
) {
|
|
||||||
this.#serial = serial;
|
|
||||||
this.#maxPayloadSize = maxPayloadSize;
|
|
||||||
this.#banner = banner;
|
|
||||||
this.#port = port;
|
|
||||||
this.#port.onmessage = async (event) => {
|
|
||||||
const message = event.data;
|
|
||||||
switch (message.type) {
|
|
||||||
case "connect":
|
|
||||||
if (message.result) {
|
|
||||||
this.#operations.resolve(message.id, message.port);
|
|
||||||
} else {
|
|
||||||
this.#operations.reject(
|
|
||||||
message.id,
|
|
||||||
new Error("failed to connect")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "reverse-tunnel":
|
|
||||||
{
|
|
||||||
const handler = this.#reverseTunnels.get(
|
|
||||||
message.address
|
|
||||||
);
|
|
||||||
if (!handler) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const socket = new SharedWorkerSocket(
|
|
||||||
message.port,
|
|
||||||
message.address
|
|
||||||
);
|
|
||||||
await handler(socket);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "add-reverse-tunnel":
|
|
||||||
if (message.result) {
|
|
||||||
this.#operations.resolve(message.id, message.address);
|
|
||||||
} else {
|
|
||||||
this.#operations.reject(
|
|
||||||
message.id,
|
|
||||||
new Error(message.error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "remove-reverse-tunnel":
|
|
||||||
case "clear-reverse-tunnels":
|
|
||||||
if (message.result) {
|
|
||||||
this.#operations.resolve(message.id, undefined);
|
|
||||||
} else {
|
|
||||||
this.#operations.reject(
|
|
||||||
message.id,
|
|
||||||
new Error(message.error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "close":
|
|
||||||
this.#disconnected.resolve();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async connect(service: string): Promise<AdbSocket> {
|
|
||||||
const [id, promise] = this.#operations.add<MessagePort>();
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "connect",
|
|
||||||
id,
|
|
||||||
service,
|
|
||||||
});
|
|
||||||
const port = await promise;
|
|
||||||
return new SharedWorkerSocket(port, service);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async addReverseTunnel(
|
|
||||||
handler: AdbIncomingSocketHandler,
|
|
||||||
address?: string
|
|
||||||
): Promise<string> {
|
|
||||||
const [id, promise] = this.#operations.add<string>();
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "add-reverse-tunnel",
|
|
||||||
id,
|
|
||||||
address,
|
|
||||||
});
|
|
||||||
address = await promise;
|
|
||||||
this.#reverseTunnels.set(address, handler);
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async removeReverseTunnel(address: string): Promise<void> {
|
|
||||||
const [id, promise] = this.#operations.add<void>();
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "remove-reverse-tunnel",
|
|
||||||
id,
|
|
||||||
address,
|
|
||||||
});
|
|
||||||
await promise;
|
|
||||||
this.#reverseTunnels.delete(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async clearReverseTunnels(): Promise<void> {
|
|
||||||
const [id, promise] = this.#operations.add<void>();
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "clear-reverse-tunnels",
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
await promise;
|
|
||||||
this.#reverseTunnels.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public close() {
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "close",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SharedWorkerDaemonConnectionOwner {
|
|
||||||
#port: MessagePort;
|
|
||||||
#connection: ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>;
|
|
||||||
#writer: WritableStreamDefaultWriter<Consumable<AdbPacketInit>>;
|
|
||||||
#pendingWrite: PromiseResolver<void> | undefined;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
port: MessagePort,
|
|
||||||
connection: ReadableWritablePair<
|
|
||||||
AdbPacketData,
|
|
||||||
Consumable<AdbPacketInit>
|
|
||||||
>
|
|
||||||
) {
|
|
||||||
this.#port = port;
|
|
||||||
this.#connection = connection;
|
|
||||||
this.#writer = connection.writable.getWriter();
|
|
||||||
|
|
||||||
this.#connection.readable.pipeTo(
|
|
||||||
new WritableStream<AdbPacketData>({
|
|
||||||
write: async (chunk) => {
|
|
||||||
console.log("connection in", chunk);
|
|
||||||
this.#pendingWrite = new PromiseResolver();
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "data",
|
|
||||||
payload: chunk,
|
|
||||||
});
|
|
||||||
await this.#pendingWrite.promise;
|
|
||||||
this.#pendingWrite = undefined;
|
|
||||||
},
|
|
||||||
close: () => {
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "close",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
this.#port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| { type: "data"; payload: AdbPacketInit }
|
|
||||||
| { type: "ack" };
|
|
||||||
switch (message.type) {
|
|
||||||
case "data":
|
|
||||||
console.log("connection out", message.payload);
|
|
||||||
await ConsumableWritableStream.write(
|
|
||||||
this.#writer,
|
|
||||||
message.payload
|
|
||||||
);
|
|
||||||
this.#port.postMessage({
|
|
||||||
type: "ack",
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "ack":
|
|
||||||
this.#pendingWrite!.resolve();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Home() {
|
|
||||||
const [adb, setAdb] = createSignal<Adb>();
|
|
||||||
|
|
||||||
let operations = new AsyncOperationManager();
|
|
||||||
let port!: MessagePort;
|
|
||||||
if (typeof window !== "undefined") {
|
|
||||||
const worker = new SharedWorker(
|
|
||||||
new URL("../components/worker.ts", import.meta.url),
|
|
||||||
{
|
|
||||||
type: "module",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
port = worker.port;
|
|
||||||
port.onmessage = async (event) => {
|
|
||||||
const message = event.data as
|
|
||||||
| {
|
|
||||||
type: "query-success";
|
|
||||||
id: number;
|
|
||||||
serial: string;
|
|
||||||
product: string | undefined;
|
|
||||||
model: string | undefined;
|
|
||||||
device: string | undefined;
|
|
||||||
features: AdbFeature[];
|
|
||||||
maxPayloadSize: number;
|
|
||||||
port: MessagePort;
|
|
||||||
}
|
|
||||||
| { type: "query-error"; id: number; error: string }
|
|
||||||
| {
|
|
||||||
type: "connect";
|
|
||||||
serial: string;
|
|
||||||
port: MessagePort;
|
|
||||||
};
|
|
||||||
switch (message.type) {
|
|
||||||
case "query-success":
|
|
||||||
operations.resolve(
|
|
||||||
message.id,
|
|
||||||
new SharedWorkerTransport(
|
|
||||||
message.serial,
|
|
||||||
message.maxPayloadSize,
|
|
||||||
new AdbBanner(
|
|
||||||
message.product,
|
|
||||||
message.model,
|
|
||||||
message.device,
|
|
||||||
message.features
|
|
||||||
),
|
|
||||||
message.port
|
|
||||||
)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case "query-error":
|
|
||||||
operations.reject(message.id, new Error(message.error));
|
|
||||||
break;
|
|
||||||
case "connect":
|
|
||||||
{
|
|
||||||
const [device] =
|
|
||||||
await AdbDaemonWebUsbDeviceManager.BROWSER!.getDevices(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
...ADB_DEFAULT_DEVICE_FILTER,
|
|
||||||
serialNumber: message.serial,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if (!device) {
|
|
||||||
message.port.postMessage({
|
|
||||||
type: "connect",
|
|
||||||
result: false,
|
|
||||||
});
|
|
||||||
message.port.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const connection = await device.connect();
|
|
||||||
new SharedWorkerDaemonConnectionOwner(
|
|
||||||
message.port,
|
|
||||||
connection
|
|
||||||
);
|
|
||||||
message.port.postMessage({
|
|
||||||
type: "connect",
|
|
||||||
result: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("beforeunload", () => {
|
|
||||||
port.postMessage({
|
|
||||||
type: "disconnect",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleClick = async () => {
|
|
||||||
const device =
|
|
||||||
await AdbDaemonWebUsbDeviceManager.BROWSER!.requestDevice();
|
|
||||||
if (!device) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const [id, promise] = operations.add<SharedWorkerTransport>();
|
|
||||||
port.postMessage({
|
|
||||||
type: "query",
|
|
||||||
id,
|
|
||||||
serial: device.serial,
|
|
||||||
});
|
|
||||||
const transport = await promise;
|
|
||||||
const adb = new Adb(transport);
|
|
||||||
setAdb(adb);
|
|
||||||
|
|
||||||
setInterval(async () => {
|
|
||||||
const model = await adb.getProp("ro.product.model");
|
|
||||||
console.log("model:", model);
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDisconnect = async () => {
|
|
||||||
const _adb = adb();
|
|
||||||
if (!_adb) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await _adb.close();
|
|
||||||
setAdb(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<main>
|
|
||||||
<Title>Tango</Title>
|
|
||||||
<div>{adb() ? "connected" : "disconnected"}</div>
|
|
||||||
{adb() ? (
|
|
||||||
<>
|
|
||||||
<button onClick={handleDisconnect}>Disconnect</button>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<button onClick={handleClick}>Connect</button>
|
|
||||||
)}
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"jsxImportSource": "solid-js",
|
|
||||||
"jsx": "preserve",
|
|
||||||
"strict": true,
|
|
||||||
"types": ["solid-start/env"],
|
|
||||||
"baseUrl": "./",
|
|
||||||
"paths": {
|
|
||||||
"~/*": ["./src/*"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
import solid from "solid-start/vite";
|
|
||||||
import { defineConfig } from "vite";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [solid()],
|
|
||||||
});
|
|
5259
common/config/rush/pnpm-lock.yaml
generated
5259
common/config/rush/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
|
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
|
||||||
{
|
{
|
||||||
"pnpmShrinkwrapHash": "813226994271f81ac4b322dded639b0b837e3830",
|
"pnpmShrinkwrapHash": "e4df30f56423bb267a886bf6a18f1e5de511cd8f",
|
||||||
"preferredVersionsHash": "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f"
|
"preferredVersionsHash": "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f"
|
||||||
}
|
}
|
||||||
|
|
28
common/scripts/install-run-rush-pnpm.js
Normal file
28
common/scripts/install-run-rush-pnpm.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
||||||
|
//
|
||||||
|
// This script is intended for usage in an automated build environment where the Rush command may not have
|
||||||
|
// been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush
|
||||||
|
// specified in the rush.json configuration file (if not already installed), and then pass a command-line to the
|
||||||
|
// rush-pnpm command.
|
||||||
|
//
|
||||||
|
// An example usage would be:
|
||||||
|
//
|
||||||
|
// node common/scripts/install-run-rush-pnpm.js pnpm-command
|
||||||
|
//
|
||||||
|
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
||||||
|
|
||||||
|
/******/ (() => { // webpackBootstrap
|
||||||
|
/******/ "use strict";
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
/*!*****************************************************!*\
|
||||||
|
!*** ./lib-esnext/scripts/install-run-rush-pnpm.js ***!
|
||||||
|
\*****************************************************/
|
||||||
|
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
|
// See the @microsoft/rush package's LICENSE file for license information.
|
||||||
|
require('./install-run-rush');
|
||||||
|
//# sourceMappingURL=install-run-rush-pnpm.js.map
|
||||||
|
module.exports = __webpack_exports__;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=install-run-rush-pnpm.js.map
|
|
@ -1,30 +1,3 @@
|
||||||
"use strict";
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
||||||
// See the @microsoft/rush package's LICENSE file for license information.
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
||||||
//
|
//
|
||||||
// This script is intended for usage in an automated build environment where the Rush command may not have
|
// This script is intended for usage in an automated build environment where the Rush command may not have
|
||||||
|
@ -35,9 +8,115 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// node common/scripts/install-run-rush.js install
|
// node common/scripts/install-run-rush.js install
|
||||||
//
|
//
|
||||||
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const fs = __importStar(require("fs"));
|
/******/ (() => { // webpackBootstrap
|
||||||
const install_run_1 = require("./install-run");
|
/******/ "use strict";
|
||||||
|
/******/ var __webpack_modules__ = ({
|
||||||
|
|
||||||
|
/***/ 657147:
|
||||||
|
/*!*********************!*\
|
||||||
|
!*** external "fs" ***!
|
||||||
|
\*********************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("fs");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 371017:
|
||||||
|
/*!***********************!*\
|
||||||
|
!*** external "path" ***!
|
||||||
|
\***********************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("path");
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
/******/ });
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var __webpack_module_cache__ = {};
|
||||||
|
/******/
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||||
|
/******/ if (cachedModule !== undefined) {
|
||||||
|
/******/ return cachedModule.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||||
|
/******/ // no module.id needed
|
||||||
|
/******/ // no module.loaded needed
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||||
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/compat get default export */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __webpack_require__.n = (module) => {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ () => (module['default']) :
|
||||||
|
/******/ () => (module);
|
||||||
|
/******/ __webpack_require__.d(getter, { a: getter });
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __webpack_require__.d = (exports, definition) => {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __webpack_require__.r = (exports) => {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
|
(() => {
|
||||||
|
/*!************************************************!*\
|
||||||
|
!*** ./lib-esnext/scripts/install-run-rush.js ***!
|
||||||
|
\************************************************/
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ 371017);
|
||||||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fs */ 657147);
|
||||||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
|
// See the @microsoft/rush package's LICENSE file for license information.
|
||||||
|
|
||||||
|
|
||||||
|
const { installAndRun, findRushJsonFolder, RUSH_JSON_FILENAME, runWithErrorAndStatusCode } = require('./install-run');
|
||||||
const PACKAGE_NAME = '@microsoft/rush';
|
const PACKAGE_NAME = '@microsoft/rush';
|
||||||
const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION';
|
const RUSH_PREVIEW_VERSION = 'RUSH_PREVIEW_VERSION';
|
||||||
const INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_RUSH_LOCKFILE_PATH';
|
const INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_RUSH_LOCKFILE_PATH';
|
||||||
|
@ -47,10 +126,10 @@ function _getRushVersion(logger) {
|
||||||
logger.info(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`);
|
logger.info(`Using Rush version from environment variable ${RUSH_PREVIEW_VERSION}=${rushPreviewVersion}`);
|
||||||
return rushPreviewVersion;
|
return rushPreviewVersion;
|
||||||
}
|
}
|
||||||
const rushJsonFolder = (0, install_run_1.findRushJsonFolder)();
|
const rushJsonFolder = findRushJsonFolder();
|
||||||
const rushJsonPath = path.join(rushJsonFolder, install_run_1.RUSH_JSON_FILENAME);
|
const rushJsonPath = path__WEBPACK_IMPORTED_MODULE_0__.join(rushJsonFolder, RUSH_JSON_FILENAME);
|
||||||
try {
|
try {
|
||||||
const rushJsonContents = fs.readFileSync(rushJsonPath, 'utf-8');
|
const rushJsonContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(rushJsonPath, 'utf-8');
|
||||||
// Use a regular expression to parse out the rushVersion value because rush.json supports comments,
|
// Use a regular expression to parse out the rushVersion value because rush.json supports comments,
|
||||||
// but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.
|
// but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.
|
||||||
const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/);
|
const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/);
|
||||||
|
@ -62,12 +141,22 @@ function _getRushVersion(logger) {
|
||||||
'using an unexpected syntax.');
|
'using an unexpected syntax.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function _getBin(scriptName) {
|
||||||
|
switch (scriptName.toLowerCase()) {
|
||||||
|
case 'install-run-rush-pnpm.js':
|
||||||
|
return 'rush-pnpm';
|
||||||
|
case 'install-run-rushx.js':
|
||||||
|
return 'rushx';
|
||||||
|
default:
|
||||||
|
return 'rush';
|
||||||
|
}
|
||||||
|
}
|
||||||
function _run() {
|
function _run() {
|
||||||
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
|
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
|
||||||
// Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
|
// Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
|
||||||
// appropriate binary inside the rush package to run
|
// appropriate binary inside the rush package to run
|
||||||
const scriptName = path.basename(scriptPath);
|
const scriptName = path__WEBPACK_IMPORTED_MODULE_0__.basename(scriptPath);
|
||||||
const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush';
|
const bin = _getBin(scriptName);
|
||||||
if (!nodePath || !scriptPath) {
|
if (!nodePath || !scriptPath) {
|
||||||
throw new Error('Unexpected exception: could not detect node path or script path');
|
throw new Error('Unexpected exception: could not detect node path or script path');
|
||||||
}
|
}
|
||||||
|
@ -94,7 +183,10 @@ function _run() {
|
||||||
}
|
}
|
||||||
if (!commandFound) {
|
if (!commandFound) {
|
||||||
console.log(`Usage: ${scriptName} <command> [args...]`);
|
console.log(`Usage: ${scriptName} <command> [args...]`);
|
||||||
if (scriptName === 'install-run-rush.js') {
|
if (scriptName === 'install-run-rush-pnpm.js') {
|
||||||
|
console.log(`Example: ${scriptName} pnpm-command`);
|
||||||
|
}
|
||||||
|
else if (scriptName === 'install-run-rush.js') {
|
||||||
console.log(`Example: ${scriptName} build --to myproject`);
|
console.log(`Example: ${scriptName} build --to myproject`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -102,15 +194,21 @@ function _run() {
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
(0, install_run_1.runWithErrorAndStatusCode)(logger, () => {
|
runWithErrorAndStatusCode(logger, () => {
|
||||||
const version = _getRushVersion(logger);
|
const version = _getRushVersion(logger);
|
||||||
logger.info(`The rush.json configuration requests Rush version ${version}`);
|
logger.info(`The rush.json configuration requests Rush version ${version}`);
|
||||||
const lockFilePath = process.env[INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE];
|
const lockFilePath = process.env[INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE];
|
||||||
if (lockFilePath) {
|
if (lockFilePath) {
|
||||||
logger.info(`Found ${INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE}="${lockFilePath}", installing with lockfile.`);
|
logger.info(`Found ${INSTALL_RUN_RUSH_LOCKFILE_PATH_VARIABLE}="${lockFilePath}", installing with lockfile.`);
|
||||||
}
|
}
|
||||||
return (0, install_run_1.installAndRun)(logger, PACKAGE_NAME, version, bin, packageBinArgs, lockFilePath);
|
return installAndRun(logger, PACKAGE_NAME, version, bin, packageBinArgs, lockFilePath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_run();
|
_run();
|
||||||
//# sourceMappingURL=install-run-rush.js.map
|
//# sourceMappingURL=install-run-rush.js.map
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = __webpack_exports__;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=install-run-rush.js.map
|
|
@ -1,7 +1,3 @@
|
||||||
"use strict";
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
||||||
// See the @microsoft/rush package's LICENSE file for license information.
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
||||||
//
|
//
|
||||||
// This script is intended for usage in an automated build environment where the Rush command may not have
|
// This script is intended for usage in an automated build environment where the Rush command may not have
|
||||||
|
@ -14,5 +10,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// node common/scripts/install-run-rushx.js custom-command
|
// node common/scripts/install-run-rushx.js custom-command
|
||||||
//
|
//
|
||||||
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
||||||
require("./install-run-rush");
|
|
||||||
|
/******/ (() => { // webpackBootstrap
|
||||||
|
/******/ "use strict";
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
/*!*************************************************!*\
|
||||||
|
!*** ./lib-esnext/scripts/install-run-rushx.js ***!
|
||||||
|
\*************************************************/
|
||||||
|
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
|
// See the @microsoft/rush package's LICENSE file for license information.
|
||||||
|
require('./install-run-rush');
|
||||||
|
//# sourceMappingURL=install-run-rushx.js.map
|
||||||
|
module.exports = __webpack_exports__;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
//# sourceMappingURL=install-run-rushx.js.map
|
//# sourceMappingURL=install-run-rushx.js.map
|
|
@ -1,31 +1,3 @@
|
||||||
"use strict";
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
||||||
// See the @microsoft/rush package's LICENSE file for license information.
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.runWithErrorAndStatusCode = exports.installAndRun = exports.findRushJsonFolder = exports.getNpmPath = exports.RUSH_JSON_FILENAME = void 0;
|
|
||||||
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
// THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
|
||||||
//
|
//
|
||||||
// This script is intended for usage in an automated build environment where a Node tool may not have
|
// This script is intended for usage in an automated build environment where a Node tool may not have
|
||||||
|
@ -36,41 +8,30 @@ exports.runWithErrorAndStatusCode = exports.installAndRun = exports.findRushJson
|
||||||
// node common/scripts/install-run.js qrcode@1.2.2 qrcode https://rushjs.io
|
// node common/scripts/install-run.js qrcode@1.2.2 qrcode https://rushjs.io
|
||||||
//
|
//
|
||||||
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
// For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
|
||||||
const childProcess = __importStar(require("child_process"));
|
|
||||||
const fs = __importStar(require("fs"));
|
/******/ (() => { // webpackBootstrap
|
||||||
const os = __importStar(require("os"));
|
/******/ "use strict";
|
||||||
const path = __importStar(require("path"));
|
/******/ var __webpack_modules__ = ({
|
||||||
exports.RUSH_JSON_FILENAME = 'rush.json';
|
|
||||||
const RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME = 'RUSH_TEMP_FOLDER';
|
/***/ 679877:
|
||||||
const INSTALL_RUN_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_LOCKFILE_PATH';
|
/*!************************************************!*\
|
||||||
const INSTALLED_FLAG_FILENAME = 'installed.flag';
|
!*** ./lib-esnext/utilities/npmrcUtilities.js ***!
|
||||||
const NODE_MODULES_FOLDER_NAME = 'node_modules';
|
\************************************************/
|
||||||
const PACKAGE_JSON_FILENAME = 'package.json';
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
/**
|
|
||||||
* Parse a package specifier (in the form of name\@version) into name and version parts.
|
__webpack_require__.r(__webpack_exports__);
|
||||||
*/
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
function _parsePackageSpecifier(rawPackageSpecifier) {
|
/* harmony export */ "syncNpmrc": () => (/* binding */ syncNpmrc)
|
||||||
rawPackageSpecifier = (rawPackageSpecifier || '').trim();
|
/* harmony export */ });
|
||||||
const separatorIndex = rawPackageSpecifier.lastIndexOf('@');
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ 657147);
|
||||||
let name;
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
let version = undefined;
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ 371017);
|
||||||
if (separatorIndex === 0) {
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
// The specifier starts with a scope and doesn't have a version specified
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
name = rawPackageSpecifier;
|
// See LICENSE in the project root for license information.
|
||||||
}
|
// IMPORTANT - do not use any non-built-in libraries in this file
|
||||||
else if (separatorIndex === -1) {
|
|
||||||
// The specifier doesn't have a version
|
|
||||||
name = rawPackageSpecifier;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
name = rawPackageSpecifier.substring(0, separatorIndex);
|
|
||||||
version = rawPackageSpecifier.substring(separatorIndex + 1);
|
|
||||||
}
|
|
||||||
if (!name) {
|
|
||||||
throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`);
|
|
||||||
}
|
|
||||||
return { name, version };
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* As a workaround, copyAndTrimNpmrcFile() copies the .npmrc file to the target folder, and also trims
|
* As a workaround, copyAndTrimNpmrcFile() copies the .npmrc file to the target folder, and also trims
|
||||||
* unusable lines from the .npmrc file.
|
* unusable lines from the .npmrc file.
|
||||||
|
@ -82,12 +43,13 @@ function _parsePackageSpecifier(rawPackageSpecifier) {
|
||||||
* we'd prefer to skip that line and continue looking in other places such as the user's
|
* we'd prefer to skip that line and continue looking in other places such as the user's
|
||||||
* home directory.
|
* home directory.
|
||||||
*
|
*
|
||||||
* IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities.copyAndTrimNpmrcFile()
|
* @returns
|
||||||
|
* The text of the the .npmrc.
|
||||||
*/
|
*/
|
||||||
function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
|
function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
|
||||||
logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
|
logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
|
||||||
logger.info(` --> "${targetNpmrcPath}"`);
|
logger.info(` --> "${targetNpmrcPath}"`);
|
||||||
let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
|
let npmrcFileLines = fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(sourceNpmrcPath).toString().split('\n');
|
||||||
npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
|
npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
|
||||||
const resultLines = [];
|
const resultLines = [];
|
||||||
// This finds environment variable tokens that look like "${VAR_NAME}"
|
// This finds environment variable tokens that look like "${VAR_NAME}"
|
||||||
|
@ -122,31 +84,212 @@ function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
|
||||||
resultLines.push(line);
|
resultLines.push(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.writeFileSync(targetNpmrcPath, resultLines.join(os.EOL));
|
const combinedNpmrc = resultLines.join('\n');
|
||||||
|
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(targetNpmrcPath, combinedNpmrc);
|
||||||
|
return combinedNpmrc;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* syncNpmrc() copies the .npmrc file to the target folder, and also trims unusable lines from the .npmrc file.
|
* syncNpmrc() copies the .npmrc file to the target folder, and also trims unusable lines from the .npmrc file.
|
||||||
* If the source .npmrc file not exist, then syncNpmrc() will delete an .npmrc that is found in the target folder.
|
* If the source .npmrc file not exist, then syncNpmrc() will delete an .npmrc that is found in the target folder.
|
||||||
*
|
*
|
||||||
* IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc()
|
* IMPORTANT: THIS CODE SHOULD BE KEPT UP TO DATE WITH Utilities._syncNpmrc()
|
||||||
|
*
|
||||||
|
* @returns
|
||||||
|
* The text of the the synced .npmrc, if one exists. If one does not exist, then undefined is returned.
|
||||||
*/
|
*/
|
||||||
function _syncNpmrc(logger, sourceNpmrcFolder, targetNpmrcFolder, useNpmrcPublish) {
|
function syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder, useNpmrcPublish, logger = {
|
||||||
const sourceNpmrcPath = path.join(sourceNpmrcFolder, !useNpmrcPublish ? '.npmrc' : '.npmrc-publish');
|
info: console.log,
|
||||||
const targetNpmrcPath = path.join(targetNpmrcFolder, '.npmrc');
|
error: console.error
|
||||||
|
}) {
|
||||||
|
const sourceNpmrcPath = path__WEBPACK_IMPORTED_MODULE_1__.join(sourceNpmrcFolder, !useNpmrcPublish ? '.npmrc' : '.npmrc-publish');
|
||||||
|
const targetNpmrcPath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetNpmrcFolder, '.npmrc');
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(sourceNpmrcPath)) {
|
if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {
|
||||||
_copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath);
|
return _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath);
|
||||||
}
|
}
|
||||||
else if (fs.existsSync(targetNpmrcPath)) {
|
else if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcPath)) {
|
||||||
// If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
|
// If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
|
||||||
logger.info(`Deleting ${targetNpmrcPath}`); // Verbose
|
logger.info(`Deleting ${targetNpmrcPath}`); // Verbose
|
||||||
fs.unlinkSync(targetNpmrcPath);
|
fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(targetNpmrcPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error(`Error syncing .npmrc file: ${e}`);
|
throw new Error(`Error syncing .npmrc file: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//# sourceMappingURL=npmrcUtilities.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 532081:
|
||||||
|
/*!********************************!*\
|
||||||
|
!*** external "child_process" ***!
|
||||||
|
\********************************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("child_process");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 657147:
|
||||||
|
/*!*********************!*\
|
||||||
|
!*** external "fs" ***!
|
||||||
|
\*********************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("fs");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 822037:
|
||||||
|
/*!*********************!*\
|
||||||
|
!*** external "os" ***!
|
||||||
|
\*********************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("os");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 371017:
|
||||||
|
/*!***********************!*\
|
||||||
|
!*** external "path" ***!
|
||||||
|
\***********************/
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = require("path");
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
/******/ });
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var __webpack_module_cache__ = {};
|
||||||
|
/******/
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||||
|
/******/ if (cachedModule !== undefined) {
|
||||||
|
/******/ return cachedModule.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||||
|
/******/ // no module.id needed
|
||||||
|
/******/ // no module.loaded needed
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||||
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/compat get default export */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __webpack_require__.n = (module) => {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ () => (module['default']) :
|
||||||
|
/******/ () => (module);
|
||||||
|
/******/ __webpack_require__.d(getter, { a: getter });
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __webpack_require__.d = (exports, definition) => {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __webpack_require__.r = (exports) => {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
|
(() => {
|
||||||
|
/*!*******************************************!*\
|
||||||
|
!*** ./lib-esnext/scripts/install-run.js ***!
|
||||||
|
\*******************************************/
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "RUSH_JSON_FILENAME": () => (/* binding */ RUSH_JSON_FILENAME),
|
||||||
|
/* harmony export */ "findRushJsonFolder": () => (/* binding */ findRushJsonFolder),
|
||||||
|
/* harmony export */ "getNpmPath": () => (/* binding */ getNpmPath),
|
||||||
|
/* harmony export */ "installAndRun": () => (/* binding */ installAndRun),
|
||||||
|
/* harmony export */ "runWithErrorAndStatusCode": () => (/* binding */ runWithErrorAndStatusCode)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! child_process */ 532081);
|
||||||
|
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fs */ 657147);
|
||||||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
|
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! os */ 822037);
|
||||||
|
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_2__);
|
||||||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! path */ 371017);
|
||||||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
|
||||||
|
/* harmony import */ var _utilities_npmrcUtilities__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utilities/npmrcUtilities */ 679877);
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
||||||
|
// See the @microsoft/rush package's LICENSE file for license information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const RUSH_JSON_FILENAME = 'rush.json';
|
||||||
|
const RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME = 'RUSH_TEMP_FOLDER';
|
||||||
|
const INSTALL_RUN_LOCKFILE_PATH_VARIABLE = 'INSTALL_RUN_LOCKFILE_PATH';
|
||||||
|
const INSTALLED_FLAG_FILENAME = 'installed.flag';
|
||||||
|
const NODE_MODULES_FOLDER_NAME = 'node_modules';
|
||||||
|
const PACKAGE_JSON_FILENAME = 'package.json';
|
||||||
|
/**
|
||||||
|
* Parse a package specifier (in the form of name\@version) into name and version parts.
|
||||||
|
*/
|
||||||
|
function _parsePackageSpecifier(rawPackageSpecifier) {
|
||||||
|
rawPackageSpecifier = (rawPackageSpecifier || '').trim();
|
||||||
|
const separatorIndex = rawPackageSpecifier.lastIndexOf('@');
|
||||||
|
let name;
|
||||||
|
let version = undefined;
|
||||||
|
if (separatorIndex === 0) {
|
||||||
|
// The specifier starts with a scope and doesn't have a version specified
|
||||||
|
name = rawPackageSpecifier;
|
||||||
|
}
|
||||||
|
else if (separatorIndex === -1) {
|
||||||
|
// The specifier doesn't have a version
|
||||||
|
name = rawPackageSpecifier;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name = rawPackageSpecifier.substring(0, separatorIndex);
|
||||||
|
version = rawPackageSpecifier.substring(separatorIndex + 1);
|
||||||
|
}
|
||||||
|
if (!name) {
|
||||||
|
throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`);
|
||||||
|
}
|
||||||
|
return { name, version };
|
||||||
|
}
|
||||||
let _npmPath = undefined;
|
let _npmPath = undefined;
|
||||||
/**
|
/**
|
||||||
* Get the absolute path to the npm executable
|
* Get the absolute path to the npm executable
|
||||||
|
@ -154,35 +297,34 @@ let _npmPath = undefined;
|
||||||
function getNpmPath() {
|
function getNpmPath() {
|
||||||
if (!_npmPath) {
|
if (!_npmPath) {
|
||||||
try {
|
try {
|
||||||
if (os.platform() === 'win32') {
|
if (os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32') {
|
||||||
// We're on Windows
|
// We're on Windows
|
||||||
const whereOutput = childProcess.execSync('where npm', { stdio: [] }).toString();
|
const whereOutput = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('where npm', { stdio: [] }).toString();
|
||||||
const lines = whereOutput.split(os.EOL).filter((line) => !!line);
|
const lines = whereOutput.split(os__WEBPACK_IMPORTED_MODULE_2__.EOL).filter((line) => !!line);
|
||||||
// take the last result, we are looking for a .cmd command
|
// take the last result, we are looking for a .cmd command
|
||||||
// see https://github.com/microsoft/rushstack/issues/759
|
// see https://github.com/microsoft/rushstack/issues/759
|
||||||
_npmPath = lines[lines.length - 1];
|
_npmPath = lines[lines.length - 1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We aren't on Windows - assume we're on *NIX or Darwin
|
// We aren't on Windows - assume we're on *NIX or Darwin
|
||||||
_npmPath = childProcess.execSync('command -v npm', { stdio: [] }).toString();
|
_npmPath = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('command -v npm', { stdio: [] }).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error(`Unable to determine the path to the NPM tool: ${e}`);
|
throw new Error(`Unable to determine the path to the NPM tool: ${e}`);
|
||||||
}
|
}
|
||||||
_npmPath = _npmPath.trim();
|
_npmPath = _npmPath.trim();
|
||||||
if (!fs.existsSync(_npmPath)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(_npmPath)) {
|
||||||
throw new Error('The NPM executable does not exist');
|
throw new Error('The NPM executable does not exist');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _npmPath;
|
return _npmPath;
|
||||||
}
|
}
|
||||||
exports.getNpmPath = getNpmPath;
|
|
||||||
function _ensureFolder(folderPath) {
|
function _ensureFolder(folderPath) {
|
||||||
if (!fs.existsSync(folderPath)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(folderPath)) {
|
||||||
const parentDir = path.dirname(folderPath);
|
const parentDir = path__WEBPACK_IMPORTED_MODULE_3__.dirname(folderPath);
|
||||||
_ensureFolder(parentDir);
|
_ensureFolder(parentDir);
|
||||||
fs.mkdirSync(folderPath);
|
fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(folderPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -196,14 +338,14 @@ function _ensureAndJoinPath(baseFolder, ...pathSegments) {
|
||||||
try {
|
try {
|
||||||
for (let pathSegment of pathSegments) {
|
for (let pathSegment of pathSegments) {
|
||||||
pathSegment = pathSegment.replace(/[\\\/]/g, '+');
|
pathSegment = pathSegment.replace(/[\\\/]/g, '+');
|
||||||
joinedPath = path.join(joinedPath, pathSegment);
|
joinedPath = path__WEBPACK_IMPORTED_MODULE_3__.join(joinedPath, pathSegment);
|
||||||
if (!fs.existsSync(joinedPath)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(joinedPath)) {
|
||||||
fs.mkdirSync(joinedPath);
|
fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(joinedPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error(`Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}`);
|
throw new Error(`Error building local installation folder (${path__WEBPACK_IMPORTED_MODULE_3__.join(baseFolder, ...pathSegments)}): ${e}`);
|
||||||
}
|
}
|
||||||
return joinedPath;
|
return joinedPath;
|
||||||
}
|
}
|
||||||
|
@ -233,8 +375,8 @@ function _resolvePackageVersion(logger, rushCommonFolder, { name, version }) {
|
||||||
// version resolves to
|
// version resolves to
|
||||||
try {
|
try {
|
||||||
const rushTempFolder = _getRushTempFolder(rushCommonFolder);
|
const rushTempFolder = _getRushTempFolder(rushCommonFolder);
|
||||||
const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush');
|
const sourceNpmrcFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushCommonFolder, 'config', 'rush');
|
||||||
_syncNpmrc(logger, sourceNpmrcFolder, rushTempFolder);
|
(0,_utilities_npmrcUtilities__WEBPACK_IMPORTED_MODULE_4__.syncNpmrc)(sourceNpmrcFolder, rushTempFolder, undefined, logger);
|
||||||
const npmPath = getNpmPath();
|
const npmPath = getNpmPath();
|
||||||
// This returns something that looks like:
|
// This returns something that looks like:
|
||||||
// @microsoft/rush@3.0.0 '3.0.0'
|
// @microsoft/rush@3.0.0 '3.0.0'
|
||||||
|
@ -242,7 +384,7 @@ function _resolvePackageVersion(logger, rushCommonFolder, { name, version }) {
|
||||||
// ...
|
// ...
|
||||||
// @microsoft/rush@3.0.20 '3.0.20'
|
// @microsoft/rush@3.0.20 '3.0.20'
|
||||||
// <blank line>
|
// <blank line>
|
||||||
const npmVersionSpawnResult = childProcess.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier'], {
|
const npmVersionSpawnResult = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier'], {
|
||||||
cwd: rushTempFolder,
|
cwd: rushTempFolder,
|
||||||
stdio: []
|
stdio: []
|
||||||
});
|
});
|
||||||
|
@ -275,32 +417,31 @@ function findRushJsonFolder() {
|
||||||
let basePath = __dirname;
|
let basePath = __dirname;
|
||||||
let tempPath = __dirname;
|
let tempPath = __dirname;
|
||||||
do {
|
do {
|
||||||
const testRushJsonPath = path.join(basePath, exports.RUSH_JSON_FILENAME);
|
const testRushJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(basePath, RUSH_JSON_FILENAME);
|
||||||
if (fs.existsSync(testRushJsonPath)) {
|
if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(testRushJsonPath)) {
|
||||||
_rushJsonFolder = basePath;
|
_rushJsonFolder = basePath;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
basePath = tempPath;
|
basePath = tempPath;
|
||||||
}
|
}
|
||||||
} while (basePath !== (tempPath = path.dirname(basePath))); // Exit the loop when we hit the disk root
|
} while (basePath !== (tempPath = path__WEBPACK_IMPORTED_MODULE_3__.dirname(basePath))); // Exit the loop when we hit the disk root
|
||||||
if (!_rushJsonFolder) {
|
if (!_rushJsonFolder) {
|
||||||
throw new Error('Unable to find rush.json.');
|
throw new Error('Unable to find rush.json.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _rushJsonFolder;
|
return _rushJsonFolder;
|
||||||
}
|
}
|
||||||
exports.findRushJsonFolder = findRushJsonFolder;
|
|
||||||
/**
|
/**
|
||||||
* Detects if the package in the specified directory is installed
|
* Detects if the package in the specified directory is installed
|
||||||
*/
|
*/
|
||||||
function _isPackageAlreadyInstalled(packageInstallFolder) {
|
function _isPackageAlreadyInstalled(packageInstallFolder) {
|
||||||
try {
|
try {
|
||||||
const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
||||||
if (!fs.existsSync(flagFilePath)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(flagFilePath)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const fileContents = fs.readFileSync(flagFilePath).toString();
|
const fileContents = fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(flagFilePath).toString();
|
||||||
return fileContents.trim() === process.version;
|
return fileContents.trim() === process.version;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -312,7 +453,7 @@ function _isPackageAlreadyInstalled(packageInstallFolder) {
|
||||||
*/
|
*/
|
||||||
function _deleteFile(file) {
|
function _deleteFile(file) {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file);
|
fs__WEBPACK_IMPORTED_MODULE_1__.unlinkSync(file);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
|
if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
|
||||||
|
@ -328,19 +469,19 @@ function _deleteFile(file) {
|
||||||
*/
|
*/
|
||||||
function _cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath) {
|
function _cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath) {
|
||||||
try {
|
try {
|
||||||
const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
const flagFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
||||||
_deleteFile(flagFile);
|
_deleteFile(flagFile);
|
||||||
const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json');
|
const packageLockFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, 'package-lock.json');
|
||||||
if (lockFilePath) {
|
if (lockFilePath) {
|
||||||
fs.copyFileSync(lockFilePath, packageLockFile);
|
fs__WEBPACK_IMPORTED_MODULE_1__.copyFileSync(lockFilePath, packageLockFile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Not running `npm ci`, so need to cleanup
|
// Not running `npm ci`, so need to cleanup
|
||||||
_deleteFile(packageLockFile);
|
_deleteFile(packageLockFile);
|
||||||
const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);
|
const nodeModulesFolder = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);
|
||||||
if (fs.existsSync(nodeModulesFolder)) {
|
if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(nodeModulesFolder)) {
|
||||||
const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler');
|
const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler');
|
||||||
fs.renameSync(nodeModulesFolder, path.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`));
|
fs__WEBPACK_IMPORTED_MODULE_1__.renameSync(nodeModulesFolder, path__WEBPACK_IMPORTED_MODULE_3__.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,8 +501,8 @@ function _createPackageJson(packageInstallFolder, name, version) {
|
||||||
repository: "DON'T WARN",
|
repository: "DON'T WARN",
|
||||||
license: 'MIT'
|
license: 'MIT'
|
||||||
};
|
};
|
||||||
const packageJsonPath = path.join(packageInstallFolder, PACKAGE_JSON_FILENAME);
|
const packageJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, PACKAGE_JSON_FILENAME);
|
||||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));
|
fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error(`Unable to create package.json: ${e}`);
|
throw new Error(`Unable to create package.json: ${e}`);
|
||||||
|
@ -374,7 +515,7 @@ function _installPackage(logger, packageInstallFolder, name, version, command) {
|
||||||
try {
|
try {
|
||||||
logger.info(`Installing ${name}...`);
|
logger.info(`Installing ${name}...`);
|
||||||
const npmPath = getNpmPath();
|
const npmPath = getNpmPath();
|
||||||
const result = childProcess.spawnSync(npmPath, [command], {
|
const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(npmPath, [command], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
cwd: packageInstallFolder,
|
cwd: packageInstallFolder,
|
||||||
env: process.env
|
env: process.env
|
||||||
|
@ -392,17 +533,17 @@ function _installPackage(logger, packageInstallFolder, name, version, command) {
|
||||||
* Get the ".bin" path for the package.
|
* Get the ".bin" path for the package.
|
||||||
*/
|
*/
|
||||||
function _getBinPath(packageInstallFolder, binName) {
|
function _getBinPath(packageInstallFolder, binName) {
|
||||||
const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
|
const binFolderPath = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
|
||||||
const resolvedBinName = os.platform() === 'win32' ? `${binName}.cmd` : binName;
|
const resolvedBinName = os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32' ? `${binName}.cmd` : binName;
|
||||||
return path.resolve(binFolderPath, resolvedBinName);
|
return path__WEBPACK_IMPORTED_MODULE_3__.resolve(binFolderPath, resolvedBinName);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Write a flag file to the package's install directory, signifying that the install was successful.
|
* Write a flag file to the package's install directory, signifying that the install was successful.
|
||||||
*/
|
*/
|
||||||
function _writeFlagFile(packageInstallFolder) {
|
function _writeFlagFile(packageInstallFolder) {
|
||||||
try {
|
try {
|
||||||
const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
|
||||||
fs.writeFileSync(flagFilePath, process.version);
|
fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(flagFilePath, process.version);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`);
|
throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`);
|
||||||
|
@ -410,14 +551,14 @@ function _writeFlagFile(packageInstallFolder) {
|
||||||
}
|
}
|
||||||
function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
|
function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
|
||||||
const rushJsonFolder = findRushJsonFolder();
|
const rushJsonFolder = findRushJsonFolder();
|
||||||
const rushCommonFolder = path.join(rushJsonFolder, 'common');
|
const rushCommonFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushJsonFolder, 'common');
|
||||||
const rushTempFolder = _getRushTempFolder(rushCommonFolder);
|
const rushTempFolder = _getRushTempFolder(rushCommonFolder);
|
||||||
const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
|
const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
|
||||||
if (!_isPackageAlreadyInstalled(packageInstallFolder)) {
|
if (!_isPackageAlreadyInstalled(packageInstallFolder)) {
|
||||||
// The package isn't already installed
|
// The package isn't already installed
|
||||||
_cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath);
|
_cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath);
|
||||||
const sourceNpmrcFolder = path.join(rushCommonFolder, 'config', 'rush');
|
const sourceNpmrcFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushCommonFolder, 'config', 'rush');
|
||||||
_syncNpmrc(logger, sourceNpmrcFolder, packageInstallFolder);
|
(0,_utilities_npmrcUtilities__WEBPACK_IMPORTED_MODULE_4__.syncNpmrc)(sourceNpmrcFolder, packageInstallFolder, undefined, logger);
|
||||||
_createPackageJson(packageInstallFolder, packageName, packageVersion);
|
_createPackageJson(packageInstallFolder, packageName, packageVersion);
|
||||||
const command = lockFilePath ? 'ci' : 'install';
|
const command = lockFilePath ? 'ci' : 'install';
|
||||||
_installPackage(logger, packageInstallFolder, packageName, packageVersion, command);
|
_installPackage(logger, packageInstallFolder, packageName, packageVersion, command);
|
||||||
|
@ -425,9 +566,9 @@ function installAndRun(logger, packageName, packageVersion, packageBinName, pack
|
||||||
}
|
}
|
||||||
const statusMessage = `Invoking "${packageBinName} ${packageBinArgs.join(' ')}"`;
|
const statusMessage = `Invoking "${packageBinName} ${packageBinArgs.join(' ')}"`;
|
||||||
const statusMessageLine = new Array(statusMessage.length + 1).join('-');
|
const statusMessageLine = new Array(statusMessage.length + 1).join('-');
|
||||||
logger.info(os.EOL + statusMessage + os.EOL + statusMessageLine + os.EOL);
|
logger.info('\n' + statusMessage + '\n' + statusMessageLine + '\n');
|
||||||
const binPath = _getBinPath(packageInstallFolder, packageBinName);
|
const binPath = _getBinPath(packageInstallFolder, packageBinName);
|
||||||
const binFolderPath = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
|
const binFolderPath = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
|
||||||
// Windows environment variables are case-insensitive. Instead of using SpawnSyncOptions.env, we need to
|
// Windows environment variables are case-insensitive. Instead of using SpawnSyncOptions.env, we need to
|
||||||
// assign via the process.env proxy to ensure that we append to the right PATH key.
|
// assign via the process.env proxy to ensure that we append to the right PATH key.
|
||||||
const originalEnvPath = process.env.PATH || '';
|
const originalEnvPath = process.env.PATH || '';
|
||||||
|
@ -435,10 +576,10 @@ function installAndRun(logger, packageName, packageVersion, packageBinName, pack
|
||||||
try {
|
try {
|
||||||
// Node.js on Windows can not spawn a file when the path has a space on it
|
// Node.js on Windows can not spawn a file when the path has a space on it
|
||||||
// unless the path gets wrapped in a cmd friendly way and shell mode is used
|
// unless the path gets wrapped in a cmd friendly way and shell mode is used
|
||||||
const shouldUseShell = binPath.includes(' ') && os.platform() === 'win32';
|
const shouldUseShell = binPath.includes(' ') && os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32';
|
||||||
const platformBinPath = shouldUseShell ? `"${binPath}"` : binPath;
|
const platformBinPath = shouldUseShell ? `"${binPath}"` : binPath;
|
||||||
process.env.PATH = [binFolderPath, originalEnvPath].join(path.delimiter);
|
process.env.PATH = [binFolderPath, originalEnvPath].join(path__WEBPACK_IMPORTED_MODULE_3__.delimiter);
|
||||||
result = childProcess.spawnSync(platformBinPath, packageBinArgs, {
|
result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformBinPath, packageBinArgs, {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
windowsVerbatimArguments: false,
|
windowsVerbatimArguments: false,
|
||||||
shell: shouldUseShell,
|
shell: shouldUseShell,
|
||||||
|
@ -456,7 +597,6 @@ function installAndRun(logger, packageName, packageVersion, packageBinName, pack
|
||||||
throw result.error || new Error('An unknown error occurred.');
|
throw result.error || new Error('An unknown error occurred.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.installAndRun = installAndRun;
|
|
||||||
function runWithErrorAndStatusCode(logger, fn) {
|
function runWithErrorAndStatusCode(logger, fn) {
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
try {
|
try {
|
||||||
|
@ -464,16 +604,15 @@ function runWithErrorAndStatusCode(logger, fn) {
|
||||||
process.exitCode = exitCode;
|
process.exitCode = exitCode;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error(os.EOL + os.EOL + e.toString() + os.EOL + os.EOL);
|
logger.error('\n\n' + e.toString() + '\n\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.runWithErrorAndStatusCode = runWithErrorAndStatusCode;
|
|
||||||
function _run() {
|
function _run() {
|
||||||
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, rawPackageSpecifier /* qrcode@^1.2.0 */, packageBinName /* qrcode */, ...packageBinArgs /* [-f, myproject/lib] */] = process.argv;
|
const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, rawPackageSpecifier /* qrcode@^1.2.0 */, packageBinName /* qrcode */, ...packageBinArgs /* [-f, myproject/lib] */] = process.argv;
|
||||||
if (!nodePath) {
|
if (!nodePath) {
|
||||||
throw new Error('Unexpected exception: could not detect node path');
|
throw new Error('Unexpected exception: could not detect node path');
|
||||||
}
|
}
|
||||||
if (path.basename(scriptPath).toLowerCase() !== 'install-run.js') {
|
if (path__WEBPACK_IMPORTED_MODULE_3__.basename(scriptPath).toLowerCase() !== 'install-run.js') {
|
||||||
// If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control
|
// If install-run.js wasn't directly invoked, don't execute the rest of this function. Return control
|
||||||
// to the script that (presumably) imported this file
|
// to the script that (presumably) imported this file
|
||||||
return;
|
return;
|
||||||
|
@ -498,3 +637,9 @@ function _run() {
|
||||||
}
|
}
|
||||||
_run();
|
_run();
|
||||||
//# sourceMappingURL=install-run.js.map
|
//# sourceMappingURL=install-run.js.map
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = __webpack_exports__;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=install-run.js.map
|
|
@ -15,7 +15,7 @@
|
||||||
* path segment in the "$schema" field for all your Rush config files. This will ensure
|
* path segment in the "$schema" field for all your Rush config files. This will ensure
|
||||||
* correct error-underlining and tab-completion for editors such as VS Code.
|
* correct error-underlining and tab-completion for editors such as VS Code.
|
||||||
*/
|
*/
|
||||||
"rushVersion": "5.83.1",
|
"rushVersion": "5.100.1",
|
||||||
/**
|
/**
|
||||||
* The next field selects which package manager should be installed and determines its version.
|
* The next field selects which package manager should be installed and determines its version.
|
||||||
* Rush installs its own local copy of the package manager to ensure that your build process
|
* Rush installs its own local copy of the package manager to ensure that your build process
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
* Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation
|
* Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation
|
||||||
* for details about these alternatives.
|
* for details about these alternatives.
|
||||||
*/
|
*/
|
||||||
"pnpmVersion": "7.15.0",
|
"pnpmVersion": "8.6.3",
|
||||||
// "npmVersion": "6.14.15",
|
// "npmVersion": "6.14.15",
|
||||||
// "yarnVersion": "1.9.4",
|
// "yarnVersion": "1.9.4",
|
||||||
/**
|
/**
|
||||||
|
@ -502,10 +502,6 @@
|
||||||
{
|
{
|
||||||
"packageName": "@yume-chan/adb-cli",
|
"packageName": "@yume-chan/adb-cli",
|
||||||
"projectFolder": "apps/cli"
|
"projectFolder": "apps/cli"
|
||||||
},
|
|
||||||
{
|
|
||||||
"packageName": "@yume-chan/tango-web",
|
|
||||||
"projectFolder": "apps/web"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue