Coder Social home page Coder Social logo

joulgs / create-windowless-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yoavain/create-windowless-app

1.0 0.0 0.0 6.18 MB

Create a windowless NodeJS app

Home Page: https://www.npmjs.com/package/create-windowless-app

License: MIT License

Shell 0.10% JavaScript 5.45% C# 1.85% TypeScript 92.60%

create-windowless-app's Introduction

Create Windowless App

CodeQL Actions Status node types commit license create-windowless-app Known Vulnerabilities codecov Renovate visitors Downloads

Create a windowless NodeJS app.

You can also start from this template repository create-windowless-app-template

Create Windowless App works on Windows 64-bit only
If something doesn't work, please file an issue.

Pre-Requisites for template to work:

  • NodeJS version 14.17.0 or higher
  • MSBuild.exe must be in the PATH environment variable

Quick Overview

npx create-windowsless-app my-app

Note: There's an open issue regarding running npx on Windows when the user folder path contains a space. For more info and a workaround: npx#146

Or with npm

You can install create-windowsless-app globally:

npm install -g create-windowsless-app

And then you can run:

create-windowless-app my-app

npx create-windowless-app my-app

Or in interactive mode:

npx create-windowless-app --interactive

npx create-windowless-app --interactive

Project Structure

create-windowless-app creates the following files:

my-app
├── node_modules
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── webpack.config.js
├── launcher
│   ├── launcher.cs
│   ├── launcher.csproj
|   ├── launcher.ico
|   └── launcherCompiler.ts
├── resources
│   └── bin
│       └── my-app-launcher.exe
└───src
    └── index.js

No configuration or complicated folder structures, just the files you need to build your app.

Once the installation is done, you can build the project

cd my-app
npm run build

Then you can find in your my-app\dist folder the following files:

dist files

  • my-app.exe is the compiled app, with NodeJS bundled (using nexe)
  • my-app-launcher.exe is the compiled launcher.cs file that executes my-app.exe without a console window
  • snoretoast-x64.exe allows windows notification (using node-notifier)
  • my-app.log will be generated on first run (using winston logger)

create-windowless-app CLI

create-windowless-app <project-directory> [options]

Options:
    --no-typescript                 use javascript rather than typescript
    --no-husky                      do not install husky pre-commit hook for building launcher
    --skip-install                  writes dependencies to package.json without installing them
    --icon <icon>                   override default launcher icon file
    --node-version <nodeVersion>    override node version to bundle

    --interactive                   interactive mode

Only <project-directory> is required.

Why?

NodeJS does not have a native windowless mode (like java has javaw). Sometimes, you want to run an app as a scheduled task that runs in the background, or run a long task (i.e. a server) but do not want a console that must always be open. Best solution I could find is using a script that executes the NodeJS in windowless mode

This package comes to do the following:

  1. Compile a NodeJS (javascript/typescript) project into an *.exe file bundled with NodeJS, so no installation is needed
  2. Compile a C# launcher that executes the compiled project, in windowless mode

Template project

The "Hello World" template is a POC containing 2 features you might want when running a windowless app:

  1. Logger
  2. Notifications

The template project build script does the following things

  1. Compiles TypeScript to JavaScript (if in a TypeScript template)
  2. Runs WebPack to bundle all JavaScript into a single file, and copy binary files into the "dist" folder
  3. Runs nexe to compile the single WebPack JavaScript output file to an exe file bundled with NodeJS (currently, NodeJS version 14.15.3 is the latest version supplied by nexe)

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.