Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-update-notification

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-update-notification - npm Package Compare versions

Comparing version 0.1.0-alpha.0 to 0.1.0-alpha.1

README.md

67

bin/generate-version.js

@@ -7,15 +7,64 @@ #!/usr/bin/env node

const cheerio = require('cheerio');
const yargs = require('yargs');
const version = process.env.npm_package_version;
const buildPath = path.resolve(process.cwd(), process.argv[2]);
const versionPath = path.resolve(buildPath, 'version.json');
const indexPath = path.resolve(buildPath, 'index.html');
function generate(argv) {
const versionPath = path.resolve(process.cwd(), argv.v);
const indexPath = path.resolve(process.cwd(), argv.i);
fs.writeFileSync(versionPath, JSON.stringify({ version }));
try {
fs.writeFileSync(versionPath, JSON.stringify({ version }));
} catch (e) {
if (e.code === 'ENOENT') {
console.error(
`Error: incorrect path to version file. Path used: ${e.path}`
);
} else {
console.log(e);
}
process.exit(1);
}
const loadedIndex = cheerio.load(fs.readFileSync(indexPath).toString());
loadedIndex('head').append(
`<script>window.__APP_VERSION__ = ${version};</script>`
);
fs.writeFileSync(indexPath, loadedIndex.html());
let indexFile;
try {
indexFile = fs.readFileSync(indexPath);
} catch (e) {
if (e.code === 'ENOENT') {
console.error(
`Error: incorrect path to index.html. Path used: ${e.path}`
);
} else {
console.log(e);
}
process.exit(1);
}
const loadedIndex = cheerio.load(indexFile.toString());
loadedIndex('head').append(
`<script>window.__APP_VERSION__ = "${version}"; window.__APP_VERSION_FILE__ = "${argv.v}"</script>`
);
fs.writeFileSync(indexPath, loadedIndex.html());
}
const argv = yargs
.usage('Usage: $0 [options]')
.option('indexFile', {
alias: 'i',
description: 'Path to index.html',
nargs: 1,
default: 'build/index.html'
})
.option('versionFile', {
alias: 'v',
description: 'Version file target path',
nargs: 1,
default: 'build/version.json'
})
.example('$0 -i build/index.html')
.example('$0 -i build/index.html -v build/version.json')
.version(false)
.help().argv;
generate(argv);

4

es/index.d.ts

@@ -7,6 +7,6 @@ declare global {

declare type Status = 'checking' | 'current' | 'available';
export declare const useVersion: () => {
export declare const useUpdateCheck: () => {
status: Status;
refresh: () => void;
reloadPage: () => void;
};
export {};
import { useState, useEffect } from 'react';
var refresh = function () { return window.location.reload(true); };
var reloadPage = function () { return window.location.reload(true); };
var currentVersion = window.__APP_VERSION__;
export var useVersion = function () {
export var useUpdateCheck = function () {
var _a = useState('checking'), status = _a[0], setStatus = _a[1];

@@ -21,4 +21,4 @@ useEffect(function () {

});
});
return { status: status, refresh: refresh };
}, []);
return { status: status, reloadPage: reloadPage };
};

@@ -7,6 +7,6 @@ declare global {

declare type Status = 'checking' | 'current' | 'available';
export declare const useVersion: () => {
export declare const useUpdateCheck: () => {
status: Status;
refresh: () => void;
reloadPage: () => void;
};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = require("react");
var refresh = function () { return window.location.reload(true); };
var reloadPage = function () { return window.location.reload(true); };
var currentVersion = window.__APP_VERSION__;
exports.useVersion = function () {
exports.useUpdateCheck = function () {
var _a = react_1.useState('checking'), status = _a[0], setStatus = _a[1];

@@ -23,4 +23,4 @@ react_1.useEffect(function () {

});
});
return { status: status, refresh: refresh };
}, []);
return { status: status, reloadPage: reloadPage };
};
{
"name": "react-update-notification",
"version": "0.1.0-alpha.0",
"version": "0.1.0-alpha.1",
"description": "New version notification for your React application.",

@@ -36,4 +36,5 @@ "main": "lib/index.js",

"dependencies": {
"cheerio": "^1.0.0-rc.3"
"cheerio": "^1.0.0-rc.3",
"yargs": "^15.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc