roamjs-components 0.83.2 → 0.83.4
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.
- package/README.md +14 -109
- package/package.json +1 -1
- package/scripts/publishToRoamDepot.js +14 -0
- package/scripts/publishToRoamDepot.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,124 +1,29 @@
|
|
|
1
1
|
# roamjs-components
|
|
2
|
-
|
|
3
|
-
This is a collection of common UI components used by RoamJS extensions made available to make development easier for other Roam developers.
|
|
4
|
-
|
|
5
|
-
## Util
|
|
6
|
-
|
|
7
|
-
The following are a list of methods used to help interface with the RoamJS Components found in this library.
|
|
8
|
-
|
|
9
|
-
### createConfigObserver({title, config})
|
|
10
|
-
|
|
11
|
-
This is an observer that will render the `ConfigPage` UI on the page of your choosing.
|
|
12
|
-
|
|
13
|
-
* `title: string` Name of the page to render the Configuration page ui. If this page doesn't already exist in the user's Roam database, one will be created with specified default values filled in.
|
|
14
|
-
* `config: object` The metadata specifying which fields your configuration supports
|
|
15
|
-
* `tabs: object[]` The first level tabs grouping your fields. They map to first level blocks on the Roam Page.
|
|
16
|
-
* `id: string` The name of the tab to use in both the Roam UI and in the tab label. The `home` id inserts blocks at the top level of Roam.
|
|
17
|
-
* `toggleable: boolean` Whether this tab should be able to turn on and off. Turning a tab off disables the rest of the nested fields.
|
|
18
|
-
* `fields: object[]` The set of field metadata grouped in this tab. If fields is empty, it will be assumed that this tab is a state container for the extension not meant to be interacted with by the user.
|
|
19
|
-
* `title: string` The name of the field, displayed on the nested tag and in the Roam block.
|
|
20
|
-
* `description: string` The description of the field with renders next to each field label as a tooltip.
|
|
21
|
-
* `type: string` The field type, with only the following valid values:
|
|
22
|
-
* `text` Renders a text input.
|
|
23
|
-
* `number` Renders a number input.
|
|
24
|
-
* `flag` Renders a boolean checkbox.
|
|
25
|
-
* `multitext` Renders a text input that could have multiple child values. Used for an array of string values.
|
|
26
|
-
* `pages` Similar to multitext, but all values are Roam pages.
|
|
27
|
-
* `oauth` Renders a login button based on the service provider
|
|
28
|
-
* `select` Renders a dropdown with the configured options
|
|
29
|
-
* `defaultValue` The default value filled in on page creation. Field is optional and type based on type above
|
|
30
|
-
* `options` An extra object of options for configuring a field, based on the type above.
|
|
31
|
-
* `text` None
|
|
32
|
-
* `number` None
|
|
33
|
-
* `flag` None
|
|
34
|
-
* `multitext` None
|
|
35
|
-
* `pages` None
|
|
36
|
-
* `oauth`
|
|
37
|
-
* `service: string` The name of the service provider, used on the login button
|
|
38
|
-
* `getPopoutUrl: () => Promise<string>` A getter retrieving the url needed to begin the oauth process
|
|
39
|
-
* `getAuthData: (d: string) => Promise<Record<string, string>>` A getter that takes in a stringified JSON object from the oauth popout window and retrieves the auth related data.
|
|
40
|
-
* `ServiceIcon: React.FunctionComponent<React.SVGAttributes<SVGElement>>` The SVG Icon to render next to the login button.
|
|
41
|
-
* `select`
|
|
42
|
-
* `items: string[]` The set of valid options for this dopdown
|
|
43
|
-
|
|
44
|
-
### createComponentRender(FC, className)
|
|
45
|
-
|
|
46
|
-
Creates a render function for the component `FC` rendered inside of a `ComponentContainer` component. A `ComponentContainer` simulates standard Roam `{{components}}` in that they are meant to be rendered in a block with an edit pencil icon to edit the block if necessary.
|
|
47
|
-
* `FC: ReactElement` The component rendered with a `blockUid` prop that references the block the component is rendered in.
|
|
48
|
-
* `className` An optional class name to pass to the surrounding `ComponentContainer`.
|
|
49
|
-
|
|
50
|
-
### createOverlayRender(id, Overlay)
|
|
51
|
-
|
|
52
|
-
Creates a render function for the component `Overlay` mounted on a parent from the id passed to [getRenderRoot](#getRenderRoot(id)), unmounting when the overlay closes.
|
|
53
|
-
* `id: string` The id passed to the parent element rendering the Overlay, interpolated inside of `roamjs-${id}-root`.
|
|
54
|
-
* `Overlay: ({onClose: () => void}) => ReactElement` The React component rendered with a `onClose` prop to handle unmounting.
|
|
55
|
-
|
|
56
|
-
### getRenderRoot(id)
|
|
57
2
|
|
|
58
|
-
This
|
|
59
|
-
* `id: string` The id of the parent element, interpolated inside of `roamjs-${id}-root`.
|
|
60
|
-
|
|
61
|
-
### getSettingIntFromTree({tree, key, defaultValue})
|
|
62
|
-
|
|
63
|
-
This is a utility method for grabbing the integer value of a node from a tree by a given key.
|
|
64
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
65
|
-
* `key: string` The key used to find the desired node
|
|
66
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to 0.
|
|
67
|
-
|
|
68
|
-
### getSettingValueFromTree
|
|
69
|
-
|
|
70
|
-
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
71
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
72
|
-
* `key: string` The key used to find the desired node
|
|
73
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
74
|
-
|
|
75
|
-
### getSettingValuesFromTree
|
|
76
|
-
|
|
77
|
-
This is a utility method for grabbing the string value of a node from a tree by a given key.
|
|
78
|
-
* `tree: TextNode[]` The array of `TextNode` to search through.
|
|
79
|
-
* `key: string` The key used to find the desired node
|
|
80
|
-
* `defaultValue?: number` The default value the getter should have if there are no nodes with the specified key, defaulted to an empty string.
|
|
81
|
-
|
|
82
|
-
### addInputSetting
|
|
83
|
-
|
|
84
|
-
This is a utility method for adding a value as part of multiple to a key by making it a descendant of node in the tree.
|
|
85
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
86
|
-
* `value: string` The value to add to the setting
|
|
87
|
-
* `key: string` The setting name
|
|
88
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
89
|
-
|
|
90
|
-
### setInputSetting
|
|
3
|
+
This is a collection of common UI components used by RoamJS extensions made available to make development easier for other Roam developers.
|
|
91
4
|
|
|
92
|
-
|
|
93
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
94
|
-
* `value: string` The value to assign to the setting
|
|
95
|
-
* `key: string` The setting name
|
|
96
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
5
|
+
The `roamjs-components` repository provides a robust set of tools and components for building extensions and integrations for the Roam Research note-taking application. Engineers can use this repo to streamline the development of Roam extensions by leveraging pre-built React components, utility functions, and custom hooks that interact with the Roam Research API. This repo addresses the real-world problem of efficiently creating and managing Roam Research extensions, enabling developers to focus on building unique features rather than handling boilerplate code.
|
|
97
6
|
|
|
98
|
-
|
|
7
|
+
The most important parts of the repo include the Components, utility functions, and database query functions. These components are organized into several directories, each serving a specific purpose:
|
|
99
8
|
|
|
100
|
-
|
|
101
|
-
* `blockUid: string` The uid of the root block housing all of settings.
|
|
102
|
-
* `values: string` The set of values to assign to the setting
|
|
103
|
-
* `key: string` The setting name
|
|
104
|
-
* `index?: number` The index where the setting should be created if new, defaulted to 0
|
|
9
|
+
[Components](https://github.com/RoamJS/roamjs-components/blob/main/docs/components.md): Found in the `…/components` directory, these components handle tasks such as configuration management, external authentication, and data visualization. Key components include configuration panels like `BlockPanel`, `BlocksPanel`, and `OauthPanel`, which are detailed in the Configuration Panels section. These components use React hooks and context to manage state and interactions within the Roam Research application.
|
|
105
10
|
|
|
106
|
-
|
|
11
|
+
[Date and Time Utilities](https://github.com/RoamJS/roamjs-components/blob/main/docs/date.md): Located in `…/date`, this directory provides functions for parsing and manipulating dates, crucial for working with Roam's daily notes. The `parseNlpDate` function uses the `chrono-node` library to parse natural language dates, while `parseRoamDateUid` converts Roam date UIDs into JavaScript Date objects. More details can be found in the Date and Time Utilities section.
|
|
107
12
|
|
|
108
|
-
The
|
|
13
|
+
[DOM Manipulation](https://github.com/RoamJS/roamjs-components/blob/main/docs/dom.md): The `…/dom` directory contains functions for interacting with the Document Object Model (DOM) within Roam Research. Functions like `addBlockCommand` and `createBlockObserver` are essential for adding new commands and observing changes in the DOM. These utilities are explained in the DOM Manipulation section.
|
|
109
14
|
|
|
110
|
-
|
|
15
|
+
[Event Handling](https://github.com/RoamJS/roamjs-components/blob/main/docs/events.md): The `…/events` directory includes the `watchOnce` function, which sets up one-time event listeners in Roam Research. This function is useful for performing actions when specific changes occur in the Roam environment, as detailed in the Event Handling section.
|
|
111
16
|
|
|
112
|
-
|
|
17
|
+
[Custom React Hooks](https://github.com/RoamJS/roamjs-components/blob/main/docs/hooks.md): Found in `…/hooks`, these hooks provide reusable functionality for managing user interactions and data structures. The `useArrowKeyDown` hook handles keyboard navigation within lists, while `useSubTree` manages sub-tree data structures. More information is available in the Custom React Hooks section.
|
|
113
18
|
|
|
114
|
-
|
|
19
|
+
[Markdown Parsing and Rendering](https://github.com/RoamJS/roamjs-components/blob/main/docs/marked.md): The `…/marked` directory customizes the `marked` library to parse and render Markdown content within Roam Research. This includes handling Roam-specific elements like block references and tags. The Markdown Parsing and Rendering section provides further details.
|
|
115
20
|
|
|
116
|
-
|
|
21
|
+
[Database Queries](https://github.com/RoamJS/roamjs-components/blob/main/docs/queries.md): The `…/queries` directory offers utility functions for interacting with the Roam Research database. Functions like `getAllBlockUids`, `getPageTitleByBlockUid`, and `getCurrentUser` retrieve various types of data from the database. These functions are crucial for building data-driven features and are discussed in the Database Queries section.
|
|
117
22
|
|
|
118
|
-
|
|
23
|
+
[Script Management](https://github.com/RoamJS/roamjs-components/blob/main/docs/scripts.md): The `…/scripts` directory includes functions for managing scripts in Roam Research. This includes functions for creating and managing script commands, as well as functions for executing scripts.
|
|
119
24
|
|
|
120
|
-
|
|
25
|
+
[Type Definitions](https://github.com/RoamJS/roamjs-components/blob/main/docs/types.md): The `…/types` directory contains TypeScript type definitions for various Roam Research components.
|
|
121
26
|
|
|
122
|
-
|
|
27
|
+
[Utility Functions](https://github.com/RoamJS/roamjs-components/blob/main/docs/util.md): The `…/util` directory includes utility functions for working with the Roam Research API. These functions are designed to simplify the process of interacting with the API.
|
|
123
28
|
|
|
124
|
-
|
|
29
|
+
[Write Operations](https://github.com/RoamJS/roamjs-components/blob/main/docs/writes.md): The `…/writes` directory includes functions for performing write operations in Roam, such as `createBlock`, `deleteBlock`, and `updateActiveBlock`. These functions handle the submission of actions to the Roam API, as detailed in the Write Operations section.
|
package/package.json
CHANGED
|
@@ -84,6 +84,20 @@ const publishToRoamDepot = ({ owner = process.env.GITHUB_REPOSITORY_OWNER, repo
|
|
|
84
84
|
(0, child_process_1.execSync)("git add --all", { stdio: "inherit" });
|
|
85
85
|
(0, child_process_1.execSync)(`git commit -m "${title}"`, { stdio: "inherit" });
|
|
86
86
|
(0, child_process_1.execSync)(`git push origin ${branch} -f`, { stdio: "inherit" });
|
|
87
|
+
console.log("Creating pull request to Roam-Research/roam-depot:");
|
|
88
|
+
console.log(`head: ${owner}:${branch}`);
|
|
89
|
+
console.log(`base: main`);
|
|
90
|
+
console.log(`title: ${title}`);
|
|
91
|
+
const options = opts();
|
|
92
|
+
const authHeader = options.headers.Authorization;
|
|
93
|
+
const maskedAuthHeader = authHeader
|
|
94
|
+
? `${authHeader.slice(0, 4)}****${authHeader.slice(-4)}`
|
|
95
|
+
: undefined;
|
|
96
|
+
console.log("Options:", {
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: maskedAuthHeader,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
87
101
|
const url = yield axios_1.default
|
|
88
102
|
.post(`https://api.github.com/repos/Roam-Research/roam-depot/pulls`, {
|
|
89
103
|
head: `${owner}:${branch}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishToRoamDepot.js","sourceRoot":"","sources":["../../src/scripts/publishToRoamDepot.ts"],"names":[],"mappings":";;;AAAA,oDAAoB;AACpB,wDAAwB;AACxB,0DAA0B;AAC1B,4DAA4B;AAC5B,iDAAyC;AACzC,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC;IAClB,OAAO,EAAE;QACP,MAAM,EAAE,6BAA6B;QACrC,aAAa,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;KACnD;CACF,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,C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AC,yBAAyB,GAAG,EAAE,CAAC,CAAC;KAC7C;IACD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAA,CAAC;AAEF,kBAAe,kBAAkB,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport axios from \"axios\";\nimport dotenv from \"dotenv\";\nimport { execSync } from \"child_process\";\ndotenv.config();\n\nconst opts = () => ({\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `token ${process.env.GITHUB_TOKEN}`,\n },\n});\n\nconst publishToRoamDepot = async ({\n owner = process.env.GITHUB_REPOSITORY_OWNER,\n repo = path.basename(process.cwd()),\n branch = repo,\n proxy = process.env.ROAMJS_PROXY || owner,\n}: {\n repo?: string;\n owner?: string;\n branch?: string;\n proxy?: string;\n} = {}) => {\n console.log(\"Attempting to publish to Roam Depot...\");\n const pr = await axios\n .get(\n `https://api.github.com/repos/Roam-Research/roam-depot/pulls?head=${owner}:${branch}`,\n opts()\n )\n .then((r) => r.data[0]?.html_url);\n const cwd = process.cwd();\n process.chdir(\"/tmp\");\n execSync(\n `git clone https://${owner}:${process.env.GITHUB_TOKEN}@github.com/${owner}/roam-depot.git`,\n { stdio: \"inherit\" }\n );\n process.chdir(\"roam-depot\");\n const manifestFile = `extensions/${proxy}/${repo.replace(\n /^roam(js)?-/,\n \"\"\n )}.json`;\n const packageJson = JSON.parse(\n fs.readFileSync(`${cwd}/package.json`).toString()\n );\n const { name: authorName, email: authorEmail } = await axios\n .get<{ name: string; email: string }>(`https://api.github.com/user`, opts())\n .then((r) => r.data)\n .catch(() => packageJson.author || {});\n execSync(`git config --global user.email \"${authorEmail}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git config --global user.name \"${authorName}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git remote add roam https://github.com/Roam-Research/roam-depot`, {\n stdio: \"inherit\",\n });\n execSync(`git pull roam main --rebase`, { stdio: \"inherit\" });\n execSync(`git push origin main -f`, { stdio: \"inherit\" });\n if (pr) {\n console.log(\"Found existing PR\");\n execSync(`git checkout ${branch}`, { stdio: \"inherit\" });\n execSync(`git rebase origin/main`, { stdio: \"inherit\" });\n const manifest = fs.readFileSync(manifestFile).toString();\n fs.writeFileSync(\n manifestFile,\n manifest.replace(\n /\"source_commit\": \"[a-f0-9]+\",/,\n `\"source_commit\": \"${process.env.GITHUB_SHA}\",`\n )\n );\n console.log(\n \"Editing\",\n manifestFile,\n \"from\",\n manifest,\n \"to\",\n process.env.GITHUB_SHA\n );\n execSync(\"git add --all\", { stdio: \"inherit\" });\n execSync(`git commit -m \"Version ${packageJson.version}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git push origin ${branch} -f`, { stdio: \"inherit\" });\n console.log(`Updated pull request: ${pr}`);\n } else {\n console.log(\"Creating new PR\");\n execSync(`git checkout -b ${branch}`, { stdio: \"inherit\" });\n if (!fs.existsSync(`extensions/${proxy}`))\n fs.mkdirSync(`extensions/${proxy}`);\n const name = repo\n .replace(/^roam(js)?-/, \"\")\n .split(\"-\")\n .map((s) => `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`)\n .join(\" \");\n if (fs.existsSync(manifestFile)) {\n const manifest = fs.readFileSync(manifestFile).toString();\n fs.writeFileSync(\n manifestFile,\n manifest.replace(\n /\"source_commit\": \"[a-f0-9]+\",/,\n `\"source_commit\": \"${process.env.GITHUB_SHA}\",`\n )\n );\n } else {\n fs.writeFileSync(\n manifestFile,\n JSON.stringify(\n {\n name,\n short_description:\n packageJson?.description ||\n \"Description missing from package json\",\n author: authorName,\n tags: packageJson?.tags || [],\n source_url: `https://github.com/${owner}/${repo}`,\n source_repo: `https://github.com/${owner}/${repo}.git`,\n source_commit: process.env.GITHUB_SHA,\n stripe_account: packageJson.stripe,\n },\n null,\n 4\n ) + \"\\n\"\n );\n }\n const title = `${name}: Version ${packageJson.version}`;\n execSync(\"git add --all\", { stdio: \"inherit\" });\n execSync(`git commit -m \"${title}\"`, { stdio: \"inherit\" });\n execSync(`git push origin ${branch} -f`, { stdio: \"inherit\" });\n const url = await axios\n .post(\n `https://api.github.com/repos/Roam-Research/roam-depot/pulls`,\n {\n head: `${owner}:${branch}`,\n base: \"main\",\n title,\n },\n opts()\n )\n .then((r) => r.data.html_url)\n .catch((e) => Promise.reject(e.response.data || e.message));\n console.log(`Created pull request: ${url}`);\n }\n process.chdir(cwd);\n};\n\nexport default publishToRoamDepot;\n"]}
|
|
1
|
+
{"version":3,"file":"publishToRoamDepot.js","sourceRoot":"","sources":["../../src/scripts/publishToRoamDepot.ts"],"names":[],"mappings":";;;AAAA,oDAAoB;AACpB,wDAAwB;AACxB,0DAA0B;AAC1B,4DAA4B;AAC5B,iDAAyC;AACzC,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC;IAClB,OAAO,EAAE;QACP,MAAM,EAAE,6BAA6B;QACrC,aAAa,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;KACnD;CACF,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAO,EAChC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAC3C,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EACnC,MAAM,GAAG,IAAI,EACb,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,MAMvC,EAAE,EAAE,EAAE;IACR,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACtD,MAAM,EAAE,GAAG,MAAM,eAAK;SACnB,GAAG,CACF,oEAAoE,KAAK,IAAI,MAAM,EAAE,EACrF,IAAI,EAAE,CACP;SACA,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,QAAQ,CAAA,EAAA,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,OAAO,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I,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;KAC7C;IACD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAA,CAAC;AAEF,kBAAe,kBAAkB,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport axios from \"axios\";\nimport dotenv from \"dotenv\";\nimport { execSync } from \"child_process\";\ndotenv.config();\n\nconst opts = () => ({\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `token ${process.env.GITHUB_TOKEN}`,\n },\n});\n\nconst publishToRoamDepot = async ({\n owner = process.env.GITHUB_REPOSITORY_OWNER,\n repo = path.basename(process.cwd()),\n branch = repo,\n proxy = process.env.ROAMJS_PROXY || owner,\n}: {\n repo?: string;\n owner?: string;\n branch?: string;\n proxy?: string;\n} = {}) => {\n console.log(\"Attempting to publish to Roam Depot...\");\n const pr = await axios\n .get(\n `https://api.github.com/repos/Roam-Research/roam-depot/pulls?head=${owner}:${branch}`,\n opts()\n )\n .then((r) => r.data[0]?.html_url);\n const cwd = process.cwd();\n process.chdir(\"/tmp\");\n execSync(\n `git clone https://${owner}:${process.env.GITHUB_TOKEN}@github.com/${owner}/roam-depot.git`,\n { stdio: \"inherit\" }\n );\n process.chdir(\"roam-depot\");\n const manifestFile = `extensions/${proxy}/${repo.replace(\n /^roam(js)?-/,\n \"\"\n )}.json`;\n const packageJson = JSON.parse(\n fs.readFileSync(`${cwd}/package.json`).toString()\n );\n const { name: authorName, email: authorEmail } = await axios\n .get<{ name: string; email: string }>(`https://api.github.com/user`, opts())\n .then((r) => r.data)\n .catch(() => packageJson.author || {});\n execSync(`git config --global user.email \"${authorEmail}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git config --global user.name \"${authorName}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git remote add roam https://github.com/Roam-Research/roam-depot`, {\n stdio: \"inherit\",\n });\n execSync(`git pull roam main --rebase`, { stdio: \"inherit\" });\n execSync(`git push origin main -f`, { stdio: \"inherit\" });\n if (pr) {\n console.log(\"Found existing PR\");\n execSync(`git checkout ${branch}`, { stdio: \"inherit\" });\n execSync(`git rebase origin/main`, { stdio: \"inherit\" });\n const manifest = fs.readFileSync(manifestFile).toString();\n fs.writeFileSync(\n manifestFile,\n manifest.replace(\n /\"source_commit\": \"[a-f0-9]+\",/,\n `\"source_commit\": \"${process.env.GITHUB_SHA}\",`\n )\n );\n console.log(\n \"Editing\",\n manifestFile,\n \"from\",\n manifest,\n \"to\",\n process.env.GITHUB_SHA\n );\n execSync(\"git add --all\", { stdio: \"inherit\" });\n execSync(`git commit -m \"Version ${packageJson.version}\"`, {\n stdio: \"inherit\",\n });\n execSync(`git push origin ${branch} -f`, { stdio: \"inherit\" });\n console.log(`Updated pull request: ${pr}`);\n } else {\n console.log(\"Creating new PR\");\n execSync(`git checkout -b ${branch}`, { stdio: \"inherit\" });\n if (!fs.existsSync(`extensions/${proxy}`))\n fs.mkdirSync(`extensions/${proxy}`);\n const name = repo\n .replace(/^roam(js)?-/, \"\")\n .split(\"-\")\n .map((s) => `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`)\n .join(\" \");\n if (fs.existsSync(manifestFile)) {\n const manifest = fs.readFileSync(manifestFile).toString();\n fs.writeFileSync(\n manifestFile,\n manifest.replace(\n /\"source_commit\": \"[a-f0-9]+\",/,\n `\"source_commit\": \"${process.env.GITHUB_SHA}\",`\n )\n );\n } else {\n fs.writeFileSync(\n manifestFile,\n JSON.stringify(\n {\n name,\n short_description:\n packageJson?.description ||\n \"Description missing from package json\",\n author: authorName,\n tags: packageJson?.tags || [],\n source_url: `https://github.com/${owner}/${repo}`,\n source_repo: `https://github.com/${owner}/${repo}.git`,\n source_commit: process.env.GITHUB_SHA,\n stripe_account: packageJson.stripe,\n },\n null,\n 4\n ) + \"\\n\"\n );\n }\n const title = `${name}: Version ${packageJson.version}`;\n execSync(\"git add --all\", { stdio: \"inherit\" });\n execSync(`git commit -m \"${title}\"`, { stdio: \"inherit\" });\n execSync(`git push origin ${branch} -f`, { stdio: \"inherit\" });\n console.log(\"Creating pull request to Roam-Research/roam-depot:\");\n console.log(`head: ${owner}:${branch}`);\n console.log(`base: main`);\n console.log(`title: ${title}`);\n const options = opts();\n const authHeader = options.headers.Authorization;\n const maskedAuthHeader = authHeader\n ? `${authHeader.slice(0, 4)}****${authHeader.slice(-4)}`\n : undefined;\n console.log(\"Options:\", {\n headers: {\n Authorization: maskedAuthHeader,\n },\n });\n const url = await axios\n .post(\n `https://api.github.com/repos/Roam-Research/roam-depot/pulls`,\n {\n head: `${owner}:${branch}`,\n base: \"main\",\n title,\n },\n opts()\n )\n .then((r) => r.data.html_url)\n .catch((e) => Promise.reject(e.response.data || e.message));\n console.log(`Created pull request: ${url}`);\n }\n process.chdir(cwd);\n};\n\nexport default publishToRoamDepot;\n"]}
|