readmeio / rdme

ReadMe's official command-line interface (CLI) and GitHub Action 🌊
https://docs.readme.com/main/docs/rdme
MIT License
103 stars 42 forks source link

v9 milestone #801

Open kanadgupta opened 1 year ago

kanadgupta commented 1 year ago

lower priority

kanadgupta commented 1 year ago

Maybe we also migrate to ESM? 😬

erunion commented 1 year ago

fwiw, iirc last time i looked into that you still needed to pass the --experimental flag to Node for ESM in order to run bin/rdme. That was like a year and a half ago though, and before we migrated to TS, so maybe things are different now.

kanadgupta commented 1 year ago

maybe we also drop Node 16 support also when that is EOL in a few weeks. we'll want to bump the version here (in addition to everywhere else):

https://github.com/readmeio/rdme/blob/9756d95f510d05d2b4cdacddf91d509b287291e0/Dockerfile#L1

erunion commented 1 year ago

Now that we've got rdme guides and rdme guides:prune aliased to rdme docs:<cmd> can we deprecate and remove rdme docs?

kanadgupta commented 1 year ago

@erunion ah yeah good callout — definitely down to add a deprecation notice but i don't think we should remove those until we're using the new /guides routes

erunion commented 12 months ago

For dumping node-fetch and formdata-node for native fetch the place where you're using formdata-node in https://github.com/readmeio/rdme/pull/856 can be replaced with this diff:

diff --git a/src/lib/streamSpecToRegistry.ts b/src/lib/streamSpecToRegistry.ts
index a73445f..9d4f68a 100644
--- a/src/lib/streamSpecToRegistry.ts
+++ b/src/lib/streamSpecToRegistry.ts
@@ -1,8 +1,4 @@
-import fs from 'node:fs';
-
-import { FormData } from 'formdata-node';
 import ora from 'ora';
-import { file as tmpFile } from 'tmp-promise';

 import { debug, oraOptions } from './logger.js';
 import readmeAPIFetch, { handleRes } from './readmeAPIFetch.js';
@@ -15,23 +11,15 @@ import readmeAPIFetch, { handleRes } from './readmeAPIFetch.js';
  */
 export default async function streamSpecToRegistry(spec: string) {
   const spinner = ora({ text: 'Staging your API definition for upload...', ...oraOptions() }).start();
-  // Create a temporary file to write the bundled spec to,
-  // which we will then stream into the form data body
-  const { path } = await tmpFile({ prefix: 'rdme-openapi-', postfix: '.json' });
-  debug(`creating temporary file at ${path}`);
-  await fs.writeFileSync(path, spec);
-  const stream = fs.createReadStream(path);
-
-  debug('file and stream created, streaming into form data payload');
+  debug('preparing spec into form data payload');
   const formData = new FormData();
-  formData.append('spec', {
-    type: 'application/json',
-    name: 'openapi.json',
-    [Symbol.toStringTag]: 'File',
-    stream() {
-      return stream;
-    },
-  });
+  formData.append(
+    spec,
+    new Blob([spec], {
+      type: 'application/json',
+    }),
+    'openapi.json',
+  );

   const options = {
     body: formData,