@sillsdev/docu-notion 0.14.0-alpha.12 → 0.14.0-alpha.14
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 +5 -2
- package/dist/images.js +8 -5
- package/dist/pull.d.ts +1 -0
- package/dist/pull.js +7 -0
- package/dist/run.js +2 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -90,7 +90,9 @@ One of the big attractions of Notion for large documentation projects is that yo
|
|
|
90
90
|
|
|
91
91
|
## Slugs
|
|
92
92
|
|
|
93
|
-
By default, pages will be given a slug based on the Notion
|
|
93
|
+
By default, pages will be given a slug based on the Notion ID. For a human-readable URL, add a notion property named `Slug` to your database pages and enter a value in there that will work well in a URL. That is, no spaces, ?, #, /, etc.
|
|
94
|
+
|
|
95
|
+
See `Options` to require slugs in Notion.
|
|
94
96
|
|
|
95
97
|
## Known Limitations
|
|
96
98
|
|
|
@@ -130,7 +132,8 @@ Options:
|
|
|
130
132
|
| -l, --log-level <level> | | Log level (choices: `info`, `verbose`, `debug`) |
|
|
131
133
|
| -i, --img-output-path <string> | | Path to directory where images will be stored. If this is not included, images will be placed in the same directory as the document that uses them, which then allows for localization of screenshots. |
|
|
132
134
|
| -p, --img-prefix-in-markdown <string> | | When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path. |
|
|
133
|
-
| -
|
|
135
|
+
| --require-slugs | | If set, docu-notion will fail if any pages it would otherwise publish are missing a slug in Notion. |
|
|
136
|
+
| -h, --help | | display help for command |
|
|
134
137
|
|
|
135
138
|
# Plugins
|
|
136
139
|
|
package/dist/images.js
CHANGED
|
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.cleanupOldImages = exports.parseImageBlock = exports.markdownToMDImageTransformer = exports.standardImageTransformer = exports.initImageHandling = void 0;
|
|
39
39
|
const fs = __importStar(require("fs-extra"));
|
|
40
40
|
const file_type_1 = __importDefault(require("file-type"));
|
|
41
|
-
const
|
|
41
|
+
const axios_1 = __importDefault(require("axios"));
|
|
42
42
|
const Path = __importStar(require("path"));
|
|
43
43
|
const MakeImagePersistencePlan_1 = require("./MakeImagePersistencePlan");
|
|
44
44
|
const log_1 = require("./log");
|
|
@@ -131,9 +131,12 @@ function processImageBlock(imageBlock, pathToParentDocument, relativePathToThisP
|
|
|
131
131
|
}
|
|
132
132
|
function readPrimaryImage(imageSet) {
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
// In Mar 2024, we started having a problem getting a particular gif from imgur using
|
|
135
|
+
// node-fetch. Switching to axios resolved it. I don't know why.
|
|
136
|
+
const response = yield axios_1.default.get(imageSet.primaryUrl, {
|
|
137
|
+
responseType: "arraybuffer",
|
|
138
|
+
});
|
|
139
|
+
imageSet.primaryBuffer = Buffer.from(response.data, "utf-8");
|
|
137
140
|
imageSet.fileType = yield file_type_1.default.fromBuffer(imageSet.primaryBuffer);
|
|
138
141
|
});
|
|
139
142
|
}
|
|
@@ -145,7 +148,7 @@ function saveImage(imageSet) {
|
|
|
145
148
|
// if we have a urls for the localized screenshot, download it
|
|
146
149
|
if ((localizedImage === null || localizedImage === void 0 ? void 0 : localizedImage.url.length) > 0) {
|
|
147
150
|
(0, log_1.verbose)(`Retrieving ${localizedImage.iso632Code} version...`);
|
|
148
|
-
const response = yield (
|
|
151
|
+
const response = yield fetch(localizedImage.url);
|
|
149
152
|
const arrayBuffer = yield response.arrayBuffer();
|
|
150
153
|
buffer = Buffer.from(arrayBuffer);
|
|
151
154
|
}
|
package/dist/pull.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type DocuNotionOptions = {
|
|
|
8
8
|
imgOutputPath: string;
|
|
9
9
|
imgPrefixInMarkdown: string;
|
|
10
10
|
statusTag: string;
|
|
11
|
+
requireSlugs?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export declare function notionPull(options: DocuNotionOptions): Promise<void>;
|
|
13
14
|
export declare function executeWithRateLimitAndRetries<T>(label: string, asyncFunction: () => Promise<T>): Promise<T>;
|
package/dist/pull.js
CHANGED
|
@@ -54,6 +54,7 @@ const counts = {
|
|
|
54
54
|
skipped_because_empty: 0,
|
|
55
55
|
skipped_because_status: 0,
|
|
56
56
|
skipped_because_level_cannot_have_content: 0,
|
|
57
|
+
error_because_no_slug: 0,
|
|
57
58
|
};
|
|
58
59
|
function notionPull(options) {
|
|
59
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -127,10 +128,16 @@ function outputPages(options, config, pages) {
|
|
|
127
128
|
++context.counts.skipped_because_status;
|
|
128
129
|
}
|
|
129
130
|
else {
|
|
131
|
+
if (options.requireSlugs && !page.hasExplicitSlug) {
|
|
132
|
+
(0, log_1.error)(`Page "${page.nameOrTitle}" is missing a required slug. (--require-slugs is set.)`);
|
|
133
|
+
++counts.error_because_no_slug;
|
|
134
|
+
}
|
|
130
135
|
const markdown = yield (0, transform_1.getMarkdownForPage)(config, context, page);
|
|
131
136
|
writePage(page, markdown);
|
|
132
137
|
}
|
|
133
138
|
}
|
|
139
|
+
if (counts.error_because_no_slug > 0)
|
|
140
|
+
(0, process_1.exit)(1);
|
|
134
141
|
(0, log_1.info)(`Finished processing ${pages.length} pages`);
|
|
135
142
|
(0, log_1.info)(JSON.stringify(counts));
|
|
136
143
|
});
|
package/dist/run.js
CHANGED
|
@@ -61,7 +61,8 @@ function run() {
|
|
|
61
61
|
"debug",
|
|
62
62
|
]))
|
|
63
63
|
.option("-i, --img-output-path <string>", "Path to directory where images will be stored. If this is not included, images will be placed in the same directory as the document that uses them, which then allows for localization of screenshots.")
|
|
64
|
-
.option("-p, --img-prefix-in-markdown <string>", "When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path.")
|
|
64
|
+
.option("-p, --img-prefix-in-markdown <string>", "When referencing an image from markdown, prefix with this path instead of the full img-output-path. Should be used only in conjunction with --img-output-path.")
|
|
65
|
+
.option("--require-slugs", "If set, docu-notion will fail if any pages it would otherwise publish are missing a slug in Notion.", false);
|
|
65
66
|
commander_1.program.showHelpAfterError();
|
|
66
67
|
commander_1.program.parse();
|
|
67
68
|
(0, log_1.setLogLevel)(commander_1.program.opts().logLevel);
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"tsc": "tsc",
|
|
13
13
|
"// test out with a private sample notion db": "",
|
|
14
14
|
"large-site-test": "npm run ts -- -n $SIL_BLOOM_DOCS_NOTION_TOKEN -r $SIL_BLOOM_DOCS_NOTION_ROOT_PAGE --locales en,fr --log-level debug",
|
|
15
|
-
"pull-test-tagged": "npm run ts -- -n $DOCU_NOTION_INTEGRATION_TOKEN -r $DOCU_NOTION_TEST_ROOT_PAGE_ID --log-level
|
|
15
|
+
"pull-test-tagged": "npm run ts -- -n $DOCU_NOTION_INTEGRATION_TOKEN -r $DOCU_NOTION_TEST_ROOT_PAGE_ID --log-level info --status-tag test",
|
|
16
16
|
"pull-test-css": "npm run ts -- --css-output-directory ./test/css -n $DOCU_NOTION_INTEGRATION_TOKEN -r $DOCU_NOTION_TEST_ROOT_PAGE_ID --log-level debug --status-tag test",
|
|
17
17
|
"pull-sample-site": "npm run ts -- -n $DOCU_NOTION_INTEGRATION_TOKEN -r $DOCU_NOTION_SAMPLE_ROOT_PAGE --log-level debug",
|
|
18
18
|
"// test with a semi-stable/public site:": "",
|
|
@@ -20,26 +20,25 @@
|
|
|
20
20
|
"pull-sample-with-paths": "npm run ts -- -n $DOCU_NOTION_INTEGRATION_TOKEN -r $DOCU_NOTION_SAMPLE_ROOT_PAGE -m ./sample --img-output-path ./sample_img"
|
|
21
21
|
},
|
|
22
22
|
"//file-type": "have to use this version before they switched to ESM, which gives a compile error related to require()",
|
|
23
|
-
"//node-fetch@2.6.6file-type": "have to use this version before they switched to ESM, which gives a compile error related to require()",
|
|
24
23
|
"//chalk@4": "also ESM related problem",
|
|
25
24
|
"//notion-client@4": "also ESM related problem",
|
|
26
25
|
"//note: ts-node": "really is a runtime dependency",
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"@notionhq/client": "2.2.3",
|
|
28
|
+
"axios": "^1.6.8",
|
|
29
29
|
"chalk": "^4.1.2",
|
|
30
30
|
"commander": "^9.2.0",
|
|
31
31
|
"cosmiconfig": "^8.0.0",
|
|
32
32
|
"cosmiconfig-typescript-loader": "^4.3.0",
|
|
33
|
-
"file-type": "16.5.
|
|
33
|
+
"file-type": "16.5.3",
|
|
34
34
|
"fs-extra": "^10.1.0",
|
|
35
35
|
"limiter": "^2.1.0",
|
|
36
36
|
"markdown-table": "^2.0.0",
|
|
37
|
-
"node-fetch": "2.6.6",
|
|
38
37
|
"notion-client": "^4",
|
|
39
38
|
"notion-to-md": "3.1.1",
|
|
40
39
|
"path": "^0.12.7",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
40
|
+
"sanitize-filename": "^1.6.3",
|
|
41
|
+
"ts-node": "^10.2.1"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -91,5 +90,5 @@
|
|
|
91
90
|
"volta": {
|
|
92
91
|
"node": "18.16.0"
|
|
93
92
|
},
|
|
94
|
-
"version": "0.14.0-alpha.
|
|
93
|
+
"version": "0.14.0-alpha.14"
|
|
95
94
|
}
|