Giter Site home page Giter Site logo

Can't make it work about crx HOT 8 CLOSED

thom4parisot avatar thom4parisot commented on May 29, 2024
Can't make it work

from crx.

Comments (8)

thom4parisot avatar thom4parisot commented on May 29, 2024

Hey @kingio,

I'm sorry to read you have some hard time making it work. Let's try to fix this together 🙂

I see you try to load the content of the ./build directory. Is it the one which contains your extension manifest.json file? Or is it the location you want to store the compiled extension to?
If you aim load() at the directory which contains your extension, it should work.

generateUpdateXML can be called only after load happened so it has to be somewhere in the chain of promises. It is not the source of your problem I suppose.

If the source code of your extension is on GitHub and the pointers I just wrote did not help, feel free to share your repo so as we can have a look at it.

from crx.

kingio avatar kingio commented on May 29, 2024

Yes, manifest was inside build directory.
I ended hardcoding the public key in your code to build the crx.

from crx.

reyoucat avatar reyoucat commented on May 29, 2024
archive
        .glob(selfie.src, {
          cwd: selfie.path,
          matchBase: true,
          ignore: ['node_modules/**', '*.pem', '.git', '*.crx']
        })
        .finalize();

maybe, ignoring the folder will resolve it. (node_modules/**)

from crx.

msakamoto-sf avatar msakamoto-sf commented on May 29, 2024

@kingio me too, same problem.

debugging with vscode, I found program abort at this line:
https://github.com/oncletom/crx/blob/master/src/crx.js#L96

 load: function (path) {
    var selfie = this;

    return resolve(path || selfie.rootDirectory)
      .then(function(metadata){
        selfie.path = metadata.path;
        selfie.src = metadata.src;

        selfie.manifest = require(join(selfie.path, "manifest.json"));
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I tried this tiny script: ( ./dist/chrome/manifest.json existed.)

const manifest = require(path.join('./dist/chrome/', 'manifest.json'))

this result:

module.js:538
    throw err;
    ^

Error: Cannot find module 'dist\chrome\manifest.json'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
...

but const manifest = require('./dist/chrome/manifest.json') works correctly (success to json read).

from crx.

msakamoto-sf avatar msakamoto-sf commented on May 29, 2024

I think this problem re-produce only at windows platform.

from crx.

msakamoto-sf avatar msakamoto-sf commented on May 29, 2024

path.join('./dist/chrome/', 'manifest.json') on windows generates dist\chrome\manifest.json.
->
const manifest = require('./dist/chrome/manifest.json') successed,
<>
const manifest = require('dist\\chrome\\manifest.json') failed.

this may be node.js require() bug on windows platform.

from crx.

msakamoto-sf avatar msakamoto-sf commented on May 29, 2024

This works on Windows10 Pro 64bit, node.js v8.9.1

function monkeyPatchedResolve (path) {
  return new Promise(function (resolve, reject) {
    return resolve({
      path: path,
      src: '**'
    })
  })
}

crx.load = (path) => {
  var selfie = crx
  return monkeyPatchedResolve(path || selfie.rootDirectory)
    .then(function (metadata) {
      selfie.path = metadata.path
      selfie.src = metadata.src
      selfie.manifest = require(selfie.path + '/manifest.json')
      selfie.loaded = true
      return selfie
    })
}
crx.load('./dist/chrome') // WARNING : './' NEEDED !!
  .then(() => {
    return crx.loadContents()
  })
  .then((zipBuffer) => {
    fs.writeFile(`build/my-ext.chrome.zip`)
    return crx.pack(zipBuffer)
  })
  .then(crxBuffer => {
    const updateXML = crx.generateUpdateXML()
    fs.writeFile(`build/chrome-update.xml`, updateXML)
    fs.writeFile(`build/my-ext.crx`, crxBuffer)
    console.log('chrome packaging done.')
  })

Good Luck !!

from crx.

thom4parisot avatar thom4parisot commented on May 29, 2024

Sorry for being late in the game.

I have setup a Windows build in the PR #76. But I struggle to reproduce the problem on any version of Node on Windows. Could it be related to the version of Windows too? We can build on Windows Server 2012 R2 or Windows Server 2016.

Let me know, I'd be happy to see this one fixed.

from crx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.