Skip to content

Commit

Permalink
chore: switch to jsdocs (#568)
Browse files Browse the repository at this point in the history
* switch to jsdoc

* convert package to esm and files to cjs

* fix linting

* fix cli

* update contributing section
  • Loading branch information
ayushmanchhabra authored May 29, 2022
1 parent 3237575 commit 34bea75
Show file tree
Hide file tree
Showing 36 changed files with 290 additions and 647 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ yarn.lock
package-lock.json

npm-debug.log
.pnpm-debug.lo
.pnpm-debug.log
yarn-debug.log*
yarn-error.log
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and L

## Installation

> Tested and runs on Node 14, 16 and 18!
Using npm:

```javascript
Expand Down Expand Up @@ -348,6 +350,16 @@ This project was created by [Steffen Müller](https://github.com/steffenmllr) an

## Contributing

### Getting Started

- Install Node.js (I'd suggest using `nvm`)
- Install your preferred package manager (doesn't have to be `pnpm`, I'm just using it as an example)
- Run `pnpm install` to install dependencies
- Run `pnpm demo` to test your changes at first glance
- Run `pnpm test` to run tests
- Don't forget to run `pnpm format` && `pnpm lint` before commiting your changes

### General Guidelines
- Whenever possible, open an issue before submitting a pull request.
- PRs should have short descriptive titles. For example:
- fix(docs): fix typo in `options.platform` description
Expand Down
90 changes: 0 additions & 90 deletions bin/nwbuild

This file was deleted.

97 changes: 97 additions & 0 deletions bin/nwbuild.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env node
const NwBuilder = require("../lib/index.cjs");
const path = require("path");
const { detectCurrentPlatform } = require("../dist/index.cjs");

const currentPlatform = detectCurrentPlatform(process);

const argv = require("yargs")
.command("$0 <path>")
.usage("Usage:\n $0 [options] [path] [-- <args>]")

.alias("p", "platforms")
.default("p", currentPlatform)
.describe(
"p",
"Platforms to build, comma-sperated, can be: \n win32, win64, osx32, osx64, linux32, linux64 or \nwin, osx, linux",
)

.version(false)
.alias("v", "version")
.default("v", "latest")
.describe("v", "The NW.js version, eg. 0.8.4")

.alias("r", "run")
.default("r", false)
.describe("r", "Runs NW.js for the current platform")
.boolean("r")

.alias("o", "buildDir")
.default("o", "./build")
.describe("o", "The build folder")

.alias("f", "forceDownload")
.default("f", false)
.describe("f", "Force download of NW.js")
.boolean("f")

.alias("n", "name")
.describe("n", "The Name of your NW.js app.")

.describe("cacheDir", "The cache folder")

.default("quiet", false)
.describe("quiet", "Disables logging")
.boolean("quiet")

.describe(
" <args>",
"Pass custom arguments to the NW.js instance \n(-r, --run mode only)",
)

// Howto Help
.help("h")
.alias("h", "help")

.wrap(100).argv;

const options = {
appName: argv.name,
files: path.resolve(process.cwd(), argv.path) + "/**/*",
flavor: argv.flavor || "sdk",
platforms: argv.platforms ? argv.platforms.split(",") : [currentPlatform],
currentPlatform: currentPlatform,
version: argv.version,
macIcns: argv.macIcns || false,
winIco: argv.winIco || false,
cacheDir: argv.cacheDir
? path.resolve(process.cwd(), argv.cacheDir)
: path.resolve(__dirname, "..", "cache"),
buildDir: path.resolve(process.cwd(), argv.buildDir),
forceDownload: argv.forceDownload,
// get all argv arguments after --
argv: process.argv.slice(
process.argv.findIndex(function firstDash(el) {
return el === "--";
}) + 1,
),
};

// Initialize Builder
const nw = new NwBuilder(options);

// Logging
if (!(argv.quiet || argv.quite)) {
nw.on("log", console.log);
}

// Build or Run the app
const np = argv.r ? nw.run() : nw.build();
np.then(function () {
process.exit(0);
}).catch(function (error) {
if (error) {
console.error(error);
process.exit(1);
}
});
1 change: 1 addition & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var d=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var s=(r,t)=>{for(var e in t)a(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!S.call(r,n)&&n!==e&&a(r,n,{get:()=>t[n],enumerable:!(f=h(t,n))||f.enumerable});return r};var l=(r,t,e)=>(e=r!=null?d(I(r)):{},u(t||!r||!r.__esModule?a(e,"default",{value:r,enumerable:!0}):e,r)),C=r=>u(a({},"__esModule",{value:!0}),r);var O={};s(O,{Platform:()=>o,checkCache:()=>c,detectCurrentPlatform:()=>i});module.exports=C(O);var x={NIX_32:"linux32",NIX_64:"linux64",OSX_32:"osx32",OSX_64:"osx64",WIN_32:"win32",WIN_64:"win64"};Object.freeze(x);var o=x;var m=l(require("fs"),1),_=l(require("path"),1),N=(r,t)=>{let e=!1;if(t.length===1&&t[0]==="*")return m.default.existsSync(r)&&m.default.readdirSync(r).length>=2;for(let f of t){if(e)return!1;m.default.existsSync(_.default.join(r,f))||(e=!0)}return!e},c=N;var X=r=>{switch(r.platform){case"darwin":return r.arch==="x64"?o.OSX_64:o.OSX_32;case"win32":return r.arch==="x64"||r.env.PROCESSOR_ARCHITEW6432?o.WIN_64:o.WIN_32;case"linux":return r.arch==="x64"?o.NIX_64:o.NIX_32;default:return}},i=X;0&&(module.exports={Platform,checkCache,detectCurrentPlatform});
15 changes: 0 additions & 15 deletions dist/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion index.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/Version.js → lib/Version.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var platforms = require("./platforms");
var platforms = require("./platforms.cjs");
var _ = require("lodash");
var semver = require("semver");

Expand Down
20 changes: 0 additions & 20 deletions lib/downloader.js → lib/downloader.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ var isWin = /^win/.test(process.platform);
var bar;

module.exports = {
checkCache: function (cachepath, files) {
var missing;

// if the version is >=0.12.3, then we don't know which files we want from the archives, so just check that the
// folder exists and has at least 3 files in it.
if (files.length === 1 && files[0] === "*") {
return fs.existsSync(cachepath) && fs.readdirSync(cachepath).length >= 2;
}

files.forEach(function (file) {
if (missing) {
return;
}
if (!fs.existsSync(path.join(cachepath, file))) {
missing = true;
}
});

return !missing;
},
clearProgressbar: function () {
bar && bar.terminate();
bar = null;
Expand Down
14 changes: 7 additions & 7 deletions lib/index.js → lib/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ var rcedit = thenify(require("rcedit"));
var winresourcer = thenify(require("winresourcer"));
var spawn = require("child_process").spawn;
var semver = require("semver");
var platformOverrides = require("./platformOverrides.js");
var platformOverrides = require("./platformOverrides.cjs");
var deprecate = require("deprecate");
var updateNotifier = require("update-notifier");
const { checkCache, detectCurrentPlatform } = require("../dist/index.js");
const { checkCache, detectCurrentPlatform } = require("../dist/index.cjs");

var NwVersions = require("./versions");
var Version = require("./Version");
var Utils = require("./utils");
var Downloader = require("./downloader");
var platforms = require("./platforms");
var NwVersions = require("./versions.cjs");
var Version = require("./Version.cjs");
var Utils = require("./utils.cjs");
var Downloader = require("./downloader.cjs");
var platforms = require("./platforms.cjs");

var pkg = require("../package.json");

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/versions.js → lib/versions.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var platforms = require("./platforms");
var platforms = require("./platforms.cjs");
var semver = require("semver");
var request = require("request");
var _ = require("lodash");
var Version = require("./Version");
var Version = require("./Version.cjs");

/**
* @param {string} url
Expand Down
Loading

0 comments on commit 34bea75

Please sign in to comment.