Skip to content

Conversation

yqs112358
Copy link
Contributor

@yqs112358 yqs112358 commented Nov 23, 2024

目前如果通过环境变量传递GOOGLE_KEY,并且将配置文件中url_submission -> google->key配置项置空时,这里

parsedGoogleKey = require(pathFn.join(base_dir, key)) || JSON.parse(process.env.GOOGLE_KEY || '{}')

require会抛出异常,导致永远输出Google key file not exist, cancel submission.,后面的JSON.parse(process.env.GOOGLE_KEY || '{}')不会被执行。
如图:
image

使用hexo-fs代替require读取google key,解决了此问题。
修复后:
image

@abnerwei abnerwei merged commit 381bac8 into abnerwei:master Nov 25, 2024
@828767
Copy link

828767 commented Dec 2, 2024

INFO  Validating config
ERROR Plugin load failed: hexo-url-submission
Error: EISDIR: illegal operation on a directory, read
INFO

yqs112358 大佬你改的这版本加载失败:

$ hexo version
INFO  Validating config
ERROR Plugin load failed: hexo-url-submission
Error: EISDIR: illegal operation on a directory, read
INFO  
  =====================[ Hexo Theme - Solitude ]=====================
       #####  ####  #     #####  ###### #     # ######   ######
      #      #    # #       #      #    #     # #      # #
       ##### #    # #       #      #    #     # #      # ######
           # #    # #       #      #    #     # #      # #
      ######  ####  ##### #####    #      ###   ######   ######
                            2.0.12
  ===================================================================
  GitHub: https://github.com/everfu/hexo-theme-solitude

hexo: 7.3.0
hexo-cli: 4.3.2
os: win32 10.0.22631 undefined
node: 20.12.0
acorn: 8.11.3
ada: 2.7.6
ares: 1.27.0
base64: 0.5.2
brotli: 1.1.0
cjs_module_lexer: 1.2.2
cldr: 44.1
icu: 74.2
llhttp: 8.1.1
modules: 115
napi: 9
nghttp2: 1.60.0
nghttp3: 0.7.0
ngtcp2: 0.8.1
openssl: 3.0.13+quic
simdutf: 4.0.8
tz: 2024a
undici: 5.28.3
unicode: 15.1
uv: 1.46.0
uvwasi: 0.0.20
v8: 11.3.244.8-node.19
zlib: 1.3.0.1-motley-40e35a7
@yqs112358
Copy link
Contributor Author

yqs112358 commented Dec 2, 2024

奇怪了,我代码里特定判定过fs.statSync(keyPath).isFile()来着🤔
哥们是用key文件还是环境变量传递授权json的?能不能贴下相关配置看看 @828767

@828767
Copy link

828767 commented Dec 2, 2024

奇怪了,我代码里特定判定过fs.statSync(keyPath).isFile()来着🤔 哥们是用key文件还是环境变量传递授权json的?能不能贴下相关配置看看 @828767

用的原先的JSON文件,文档里没见要改的说明,请问用环境变量该怎么配?_config.yml里google:值留空?

url_submission:
  enable: true
  count: 10 # Submit limit
  urls_path: 'submit_url.txt' # URL list file path
  sitemap: 'sitemap.xml' # Sitemap path(e.g. the url is like this https://abnerwei.com/baidusitemap.xml, you can fill in `baidusitemap.xml`)
  type: 'latest' # latest or all( latest: modified pages; all: posts & pages)
  channels: # included channels are `baidu`, `google`, `bing`, `shenma`
    google: # https://cloud.tencent.com/developer/article/2387384
      key: "google.json" # Google key path 与站点 _config.yml同级(e.g. `google_key.json` or `data/google_key.json`):GOOGLE_KEY
      count: 10 # Optional

@yqs112358
Copy link
Contributor Author

yqs112358 commented Dec 2, 2024

@828767 对,用环境变量的话 channels->google->key 这个配置项写空字符串就行
然后环境变量里面直接放授权json文本

@ousugo
Copy link
Contributor

ousugo commented Dec 21, 2024

@yqs112358 您好,我也碰到了相同的问题,使用 npm install --save hexo-url-submission 安装完插件以后,运行 hexo v 就直接报下面的错误:

hexo v
INFO  Validating config
ERROR Plugin load failed: hexo-url-submission
Error: EISDIR: illegal operation on a directory, read
    at async readFileHandle (node:internal/fs/promises:554:24)
hexo: 7.3.0
hexo-cli: 4.3.2
os: win32 10.0.22631 undefined
node: 22.12.0
acorn: 8.14.0
ada: 2.9.2
amaro: 0.2.0
ares: 1.34.3
brotli: 1.1.0
cjs_module_lexer: 1.4.1
cldr: 46.0
icu: 76.1
llhttp: 9.2.1
modules: 127
napi: 9
nbytes: 0.1.1
ncrypto: 0.0.1
nghttp2: 1.64.0
nghttp3: 0.7.0
ngtcp2: 1.3.0
openssl: 3.0.15+quic
simdjson: 3.10.0
simdutf: 5.6.1
sqlite: 3.47.0
tz: 2024b
undici: 6.21.0
unicode: 16.0
uv: 1.49.1
uvwasi: 0.0.21
v8: 12.4.254.21-node.21
zlib: 1.3.0.1-motley-71660e1

我是直接使用 google_key.json 文件的,json文件和 _config.yml 都放在项目根目录下

url_submission:
   enable: true
   type: 'latest' # latest or all( latest: modified pages; all: posts & pages)
   channels: # included channels are `baidu`, `google`, `bing`, `shenma`
     baidu:
       token: "xxxxxxxxxx" # Baidu Private Token
       count: 10 # Optional
     bing:
       token: "xxxxxxxxxxx" # Bing Access Token
       count: 10 # Optional
     google:
       key: "google_key.json" # Google key path (e.g. `google_key.json` or `data/google_key.json`)
       count: 10 # Optional
     shenma:
       count: 10 # Optional
       user: "" # Username used when registering
       token: "" # ShenMa Private Key
   prefix: ['/post', '/wiki'] # URL prefix
   ignore: ["/post/a*", "/post/a?c"] # URL addresses that do not need to be submitted (wildcards are supported)
   count: 10 # Submit limit
   urls_path: 'submit_url.txt' # URL list file path
   sitemap: 'sitemap.xml' # Sitemap path(e.g. the url is like this https://abnerwei.com/baidusitemap.xml, you can fill in `baidusitemap.xml`)

想请教下,这种情况应该如何修改

@yqs112358
Copy link
Contributor Author

yqs112358 commented Dec 22, 2024

image

我新开了个blog目录试了一下,发现npm install完之后node_modules/hexo-url-submission里面居然没有代码?你们的目录里面是这样吗
是不是npm发布的时候出了问题,没把代码打包上去

@ousugo
Copy link
Contributor

ousugo commented Dec 22, 2024

我靠,一样,没有代码
image

@yqs112358
Copy link
Contributor Author

应该是这个原因。我就寻思着代码里面判断过文件和目录了,不应该出问题才对。
哥们开个新issue呗

@ousugo
Copy link
Contributor

ousugo commented Dec 22, 2024

#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants