caxa icon indicating copy to clipboard operation
caxa copied to clipboard

Add support for custom icons

Open papb opened this issue 5 years ago • 7 comments

From the readme:

Features to Consider Implementing in the Future

If you’re interested in one of these features, please send a Pull Request if you can, or at least reach out to me and mention your interest, and I may get to them.

[...]

  1. Add support for custom icons [...]

Just reaching out to mention that I am very interested in the feature of custom icons.

papb avatar Mar 17 '21 12:03 papb

👍 Thanks for reaching out. We’ll get to it at some point…

leafac avatar Apr 03 '21 08:04 leafac

In relation to my other post, It would be nice to integrate this into the exes for windows

You can use rcedit to archive this, they have both standalone exes and node module

You could just simple use extra options like icon and if it's specified then it runs the rcedit afterwards to include to icon in the final exe

si458 avatar Aug 06 '21 17:08 si458

@leafac ok i managed to get it working using rcedit,

for some reason if you fully build the exe then try using rcedit, the exe gets corrupt and nothing works (DONT DO THIS) (i believe this is because the file is too big, my text example only uses the printer npm module but the exe size is 50MB)

the way i found to achieve it, was to run the rcedit BEFORE you add the tar bundle to the exe

in theory the line right under appendTarballOfBuildDirectoryToOutput is where it code needs to be put!

i hacked apart the index.js and added in the node-rcedit and works a treat now! (i dont understand typescript sorry)

so we just need a way now of passing the variables through so it knows if to add icons, extra info etc or not!

si458 avatar Aug 07 '21 12:08 si458

ok scratch my last idea, it adds the icon as expected but then it cant run because stuff is out of sync and appears to delete the CAXACAXACAXA so it generates the following error

PS C:\Users\Simon\Documents\testapp\dist> .\testapp.exe
2021/08/07 14:13:59 caxa stub: Failed to find archive (did you append the separator when building the stub?): CreateFile C:\Users\Simon\AppData\Local\Temp/caxa/applications/testapp\gk7g66egyt/0: The system cannot find the path specified.

si458 avatar Aug 07 '21 13:08 si458

ok resourcehacker works a treat! the is even a npm module too! https://www.npmjs.com/package/@lorki97/node-resourcehacker (PLEASE USE THIS ONE AND NOT OTHER AS ONLY THIS ONE SEEMS TO WORK!) you can even try using the standalone exe and it works for adding both icons and VERSION_INFO (like company name, app description, version, etc)!

si458 avatar Aug 07 '21 13:08 si458

scratch the above again, this module fully works! https://www.npmjs.com/package/changeicon - https://unpkg.com/browse/[email protected]/ it works for both icon and versioninfo! you must however put a delay of 1 second in between the commands...

EDIT: sample build.js

const caxa = require("caxa").default;
const { resolve } = require("path");
const changeIcon = require('changeicon');
const { version, description, author, name } = require('./package.json');
const { rmSync } = require("fs");
const output = resolve(__dirname, "dist", name+'.exe');
sleep = (ms) => { return new Promise(resolve => setTimeout(resolve, ms)); }
console.log('begin', output);
(async () => {
  await sleep(1000);
  console.log('removing old exe');
  try {
    await rmSync(output, { force: true });
    console.log('removed old exe');
  } catch (e) {
    console.error('file doesnt exist');
  }
  await sleep(1000);
  console.log('compiling exe');
  await caxa({
    input: ".",
    output: output,
    command: [
      "{{caxa}}/node_modules/.bin/node",
      "{{caxa}}/index.js"
    ],
    exclude: [
      'dist',
      "build.js"
    ],
  });
  await sleep(1000);
  console.log('adding metadata to exe');
  await changeIcon.changeMetaData(output, {
    CompanyName: author,
    FileDescription: description,
    FileVersion: version+'.0',
    LegalCopyright: author,
    OriginalFilename: name+'.exe',
    ProductName: name,
    ProductVersion: version+'.0'
  });
  await sleep(1000);
  await changeIcon(output, resolve(__dirname,'icon.ico'));
  await sleep(1000);
  console.log('finished');
})();

si458 avatar Aug 07 '21 14:08 si458

i have created my own module to achieve this as the other modules where flaky https://github.com/si458/changeexe i did publish to npm but i unpublished by accident! so have to wait 24hours to republish

EDIT: published to npmjs - [email protected] !

si458 avatar Aug 07 '21 19:08 si458

Hi y’all,

Thanks for using caxa and for the conversation here.

I’ve been thinking about the broad strategy employed by caxa and concluded that there is a better way to solve the problem. In this new approach the idea of custom icons don’t really apply.

It’s a different enough approach that I think it deserves a new name, and it’s part of a bigger toolset that I’m building, which I call Radically Straightforward · Package.

I’m deprecating caxa and archiving this repository. I invite you to continue the conversation in Radically Straightforward’s issues.

Best.

leafac avatar Nov 21 '23 15:11 leafac