notion-static-exporter 1.0.2 → 1.0.3
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/CHANGELOG.md +5 -0
- package/dist/cache.d.ts +4 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cli.js +41 -1
- package/examples/sync-notion.yml +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
- Fix CI: when syncing with `--out .` (GitHub Actions), preserve `.git` / `.github`
|
|
6
|
+
instead of renaming the checkout into `*.nsp-backup` (which broke Commit & push)
|
|
7
|
+
|
|
3
8
|
## 1.0.0
|
|
4
9
|
|
|
5
10
|
- Initial release: Puppeteer BFS scrape of public `notion.site` pages
|
package/dist/cache.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare function ensureCachedPageInStaging(outRoot: string, staging: stri
|
|
|
43
43
|
/**
|
|
44
44
|
* Atomically publish staging → outRoot, keeping one previous copy at backup.
|
|
45
45
|
* Live outRoot is never wiped until staging is complete.
|
|
46
|
+
*
|
|
47
|
+
* When outRoot is a git checkout (`--out .` in Actions), we must NOT rename the
|
|
48
|
+
* directory (that would move `.git` aside and leave the next step outside a repo).
|
|
49
|
+
* Instead merge staging into place while preserving `.git` / `.github`.
|
|
46
50
|
*/
|
|
47
51
|
export declare function publishStaging(outRoot: string): {
|
|
48
52
|
backup: string | null;
|
package/dist/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,eAAO,MAAM,aAAa,EAAG,CAAU,CAAC;AAC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AG7D;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAa7E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBjE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,OAAO,GAClB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAsCtC;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAQT;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAwDzE;AAED,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CA2CtD;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GACrB,MAAM,CASR"}
|
package/dist/cli.js
CHANGED
|
@@ -4666,6 +4666,30 @@ function publishStaging(outRoot) {
|
|
|
4666
4666
|
if (existsSync3(backup)) {
|
|
4667
4667
|
rmSync(backup, { recursive: true, force: true });
|
|
4668
4668
|
}
|
|
4669
|
+
const preserveRepo = existsSync3(join6(outRoot, ".git"));
|
|
4670
|
+
if (preserveRepo) {
|
|
4671
|
+
mkdirSync4(backup, { recursive: true });
|
|
4672
|
+
for (const name of readdirSync2(outRoot)) {
|
|
4673
|
+
if (PRESERVE_IN_OUT.has(name))
|
|
4674
|
+
continue;
|
|
4675
|
+
const src = join6(outRoot, name);
|
|
4676
|
+
try {
|
|
4677
|
+
cpSync(src, join6(backup, name), { recursive: true });
|
|
4678
|
+
} catch {}
|
|
4679
|
+
}
|
|
4680
|
+
for (const name of readdirSync2(outRoot)) {
|
|
4681
|
+
if (PRESERVE_IN_OUT.has(name))
|
|
4682
|
+
continue;
|
|
4683
|
+
rmSync(join6(outRoot, name), { recursive: true, force: true });
|
|
4684
|
+
}
|
|
4685
|
+
for (const name of readdirSync2(staging)) {
|
|
4686
|
+
if (PRESERVE_IN_OUT.has(name))
|
|
4687
|
+
continue;
|
|
4688
|
+
cpSync(join6(staging, name), join6(outRoot, name), { recursive: true });
|
|
4689
|
+
}
|
|
4690
|
+
rmSync(staging, { recursive: true, force: true });
|
|
4691
|
+
return { backup: siteHasContent(backup) ? backup : null };
|
|
4692
|
+
}
|
|
4669
4693
|
if (siteHasContent(outRoot)) {
|
|
4670
4694
|
try {
|
|
4671
4695
|
renameSync(outRoot, backup);
|
|
@@ -4691,6 +4715,21 @@ function restoreBackup(outRoot) {
|
|
|
4691
4715
|
if (existsSync3(staging)) {
|
|
4692
4716
|
rmSync(staging, { recursive: true, force: true });
|
|
4693
4717
|
}
|
|
4718
|
+
const preserveRepo = existsSync3(join6(outRoot, ".git"));
|
|
4719
|
+
if (preserveRepo) {
|
|
4720
|
+
for (const name of readdirSync2(outRoot)) {
|
|
4721
|
+
if (PRESERVE_IN_OUT.has(name))
|
|
4722
|
+
continue;
|
|
4723
|
+
rmSync(join6(outRoot, name), { recursive: true, force: true });
|
|
4724
|
+
}
|
|
4725
|
+
for (const name of readdirSync2(backup)) {
|
|
4726
|
+
if (PRESERVE_IN_OUT.has(name))
|
|
4727
|
+
continue;
|
|
4728
|
+
cpSync(join6(backup, name), join6(outRoot, name), { recursive: true });
|
|
4729
|
+
}
|
|
4730
|
+
rmSync(backup, { recursive: true, force: true });
|
|
4731
|
+
return true;
|
|
4732
|
+
}
|
|
4694
4733
|
const doomed = `${outRoot}.nsp-restore-old`;
|
|
4695
4734
|
if (existsSync3(outRoot)) {
|
|
4696
4735
|
if (existsSync3(doomed))
|
|
@@ -4725,9 +4764,10 @@ function pruneOrphanHtml(staging, keepFiles) {
|
|
|
4725
4764
|
}
|
|
4726
4765
|
return removed;
|
|
4727
4766
|
}
|
|
4728
|
-
var CACHE_VERSION = 1, CACHE_FILE = ".nsp-cache.json";
|
|
4767
|
+
var CACHE_VERSION = 1, CACHE_FILE = ".nsp-cache.json", PRESERVE_IN_OUT;
|
|
4729
4768
|
var init_cache = __esm(() => {
|
|
4730
4769
|
init_assets();
|
|
4770
|
+
PRESERVE_IN_OUT = new Set([".git", ".github", ".gitignore"]);
|
|
4731
4771
|
});
|
|
4732
4772
|
|
|
4733
4773
|
// src/scrape.ts
|
package/examples/sync-notion.yml
CHANGED
|
@@ -64,12 +64,20 @@ jobs:
|
|
|
64
64
|
|
|
65
65
|
- name: Commit & push
|
|
66
66
|
run: |
|
|
67
|
+
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
68
|
+
echo "ERROR: working tree is not a git repo after sync."
|
|
69
|
+
echo "Upgrade notion-static-exporter (>=1.0.2) — publish used to move .git aside when --out ."
|
|
70
|
+
ls -la
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
67
73
|
git config user.name "github-actions[bot]"
|
|
68
74
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
69
75
|
git add -A
|
|
70
76
|
# Keep local tooling / staging leftovers out of the Pages commit
|
|
71
77
|
git reset -- .notion-static-exporter 2>/dev/null || true
|
|
72
78
|
git reset -- '*.nsp-staging' '*.nsp-backup' 2>/dev/null || true
|
|
79
|
+
# Never commit the sibling backup/staging folders next to the repo
|
|
80
|
+
git reset -- ../"$(basename "$PWD")".nsp-backup ../"$(basename "$PWD")".nsp-staging 2>/dev/null || true
|
|
73
81
|
if git diff --staged --quiet; then
|
|
74
82
|
echo "No changes"
|
|
75
83
|
exit 0
|