rwsdk 0.1.7-test.20250702145135 โ†’ 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,71 +1,16 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { $ } from "../lib/$.mjs";
4
- import fs from "node:fs/promises";
5
- import { existsSync } from "node:fs";
6
4
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- const getPackageManagerInfo = (targetDir) => {
8
- if (existsSync(path.join(targetDir, "yarn.lock"))) {
9
- return { name: "yarn", lockFile: "yarn.lock", command: "add" };
10
- }
11
- if (existsSync(path.join(targetDir, "pnpm-lock.yaml"))) {
12
- return { name: "pnpm", lockFile: "pnpm-lock.yaml", command: "add" };
13
- }
14
- return { name: "npm", lockFile: "package-lock.json", command: "install" };
15
- };
16
- const performSync = async (sdkDir, targetDir) => {
17
- console.log("๐Ÿ—๏ธ rebuilding sdk...");
18
- await $({ cwd: sdkDir, stdio: "inherit", shell: true }) `pnpm build`;
19
- console.log("๐Ÿ“ฆ packing sdk...");
20
- const packResult = await $({ cwd: sdkDir, shell: true }) `npm pack`;
21
- const tarballName = packResult.stdout?.trim() ?? "";
22
- const tarballPath = path.resolve(sdkDir, tarballName);
23
- console.log(` installing ${tarballName} in ${targetDir}...`);
24
- const pm = getPackageManagerInfo(targetDir);
25
- const packageJsonPath = path.join(targetDir, "package.json");
26
- const lockfilePath = path.join(targetDir, pm.lockFile);
27
- const originalPackageJson = await fs
28
- .readFile(packageJsonPath, "utf-8")
29
- .catch(() => null);
30
- const originalLockfile = await fs
31
- .readFile(lockfilePath, "utf-8")
32
- .catch(() => null);
33
- try {
34
- let installCommand = `${pm.name} ${pm.command} ${tarballPath}`;
35
- if (pm.name === "yarn") {
36
- installCommand = `yarn add file:${tarballPath}`;
37
- }
38
- await $({
39
- cwd: targetDir,
40
- stdio: "inherit",
41
- shell: true,
42
- }) `${installCommand}`;
43
- }
44
- finally {
45
- if (originalPackageJson) {
46
- console.log("Restoring package.json...");
47
- await fs.writeFile(packageJsonPath, originalPackageJson);
48
- }
49
- if (originalLockfile) {
50
- console.log(`Restoring ${pm.lockFile}...`);
51
- await fs.writeFile(lockfilePath, originalLockfile);
52
- }
53
- await fs.unlink(tarballPath).catch(() => {
54
- // ignore if deletion fails
55
- });
56
- }
57
- console.log("โœ… done syncing");
58
- };
59
5
  export const debugSync = async (opts) => {
60
6
  const { targetDir, sdkDir = process.cwd(), dev, watch, build } = opts;
61
7
  if (!targetDir) {
62
8
  console.error("โŒ Please provide a target directory as an argument.");
63
9
  process.exit(1);
64
10
  }
65
- const thisScriptPath = fileURLToPath(import.meta.url);
66
- const syncCommand = `tsx ${thisScriptPath} --_sync ${sdkDir} ${targetDir}`;
11
+ const syncCommand = `echo ๐Ÿ—๏ธ rebuilding... && pnpm build && rm -rf ${targetDir}/node_modules/rwsdk/dist ${targetDir}/node_modules/rwsdk/package.json && echo ๐Ÿ“ syncing sdk from ${sdkDir} to ${targetDir}/node_modules/rwsdk/... && cp -r ${sdkDir}/package.json ${sdkDir}/dist ${targetDir}/node_modules/rwsdk/ && echo โœ… done syncing`;
67
12
  // Run initial sync
68
- await performSync(sdkDir, targetDir);
13
+ await $({ stdio: "inherit", shell: true }) `${syncCommand}`;
69
14
  if (!process.env.NO_CLEAN_VITE) {
70
15
  console.log("๐Ÿงน Cleaning Vite cache...");
71
16
  await $({
@@ -98,22 +43,15 @@ export const debugSync = async (opts) => {
98
43
  };
99
44
  if (import.meta.url === new URL(process.argv[1], import.meta.url).href) {
100
45
  const args = process.argv.slice(2);
101
- const flags = new Set(args.filter((arg) => arg.startsWith("--")));
102
- const positionalArgs = args.filter((arg) => !arg.startsWith("--"));
103
- if (flags.has("--_sync")) {
104
- const [sdkDir, targetDir] = positionalArgs;
105
- await performSync(sdkDir, targetDir);
106
- }
107
- else {
108
- const targetDir = positionalArgs[0] ?? process.cwd();
109
- debugSync({
110
- targetDir,
111
- sdkDir: process.env.SDK_REPO
112
- ? path.resolve(__dirname, process.env.SDK_REPO, "sdk")
113
- : path.resolve(__dirname, "..", ".."),
114
- dev: flags.has("--dev"),
115
- watch: flags.has("--watch"),
116
- build: flags.has("--build"),
117
- });
118
- }
46
+ const targetDir = args[0] ?? process.cwd();
47
+ const flags = new Set(args.slice(1));
48
+ debugSync({
49
+ targetDir,
50
+ sdkDir: process.env.SDK_REPO
51
+ ? path.resolve(__dirname, process.env.SDK_REPO, "sdk")
52
+ : path.resolve(__dirname, "..", ".."),
53
+ dev: flags.has("--dev"),
54
+ watch: flags.has("--watch"),
55
+ build: flags.has("--build"),
56
+ });
119
57
  }
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "0.1.7-test.20250702145135",
3
+ "version": "0.1.7",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {
7
- "rw-scripts": "./bin/rw-scripts.mjs",
8
- "rwsync": "./bin/rwsync"
7
+ "rw-scripts": "./bin/rw-scripts.mjs"
9
8
  },
10
9
  "files": [
11
10
  "./README.md",
12
- "./dist",
13
- "./bin"
11
+ "./dist"
14
12
  ],
15
13
  "exports": {
16
14
  "./vite": {
package/bin/rwsync DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/sh
2
- DIR=$PWD && (cd "${@:-$SDK_REPO}/sdk" && pnpm debug:sync $DIR)