This commit is contained in:
Lukáš Kaňka
2023-08-15 18:35:50 +02:00
commit ea3e372146
10019 changed files with 2548539 additions and 0 deletions

6
CyLukTs/lukan/node_modules/getos/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,6 @@
language: node_js
node_js:
- 10
- 12
- 13
sudo: false

20
CyLukTs/lukan/node_modules/getos/Dockerfile generated vendored Normal file
View File

@ -0,0 +1,20 @@
FROM debian:7.4
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
# Setup NodeSource Official PPA
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

21
CyLukTs/lukan/node_modules/getos/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 William Blankenship
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

79
CyLukTs/lukan/node_modules/getos/README.md generated vendored Normal file
View File

@ -0,0 +1,79 @@
# getos
[![Greenkeeper badge](https://badges.greenkeeper.io/retrohacker/getos.svg)](https://greenkeeper.io/)
![getos](./imgs/logo.png)
[![Build Status](https://travis-ci.org/retrohacker/getos.png?branch=master)](https://travis-ci.org/retrohacker/getos) ![](https://img.shields.io/github/issues/retrohacker/getos.svg) ![](https://img.shields.io/npm/dm/getos.svg) ![](https://img.shields.io/npm/v/getos.svg) ![](https://img.shields.io/npm/l/getos.svg) ![](https://img.shields.io/twitter/url/https/github.com/retrohacker/getos.svg?style=social)
[![NPM](https://nodei.co/npm/getos.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/getos/)[![NPM](https://nodei.co/npm-dl/getos.png?months=9&height=3)](https://nodei.co/npm/getos/)
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
Get the OS/Distribution name of the environment you are working on
## Problem
`os.platform()` returns `linux`. If you want the distrubtion name, you're out of luck.
## Solution
This. Simply call:
```js
var getos = require('getos')
getos(function(e,os) {
if(e) return console.log(e)
console.log("Your OS is:" +JSON.stringify(os))
})
```
The `os` object conforms to:
```js
{
os: [OS NAME],
dist:[DIST NAME],
codename:[CODENAME],
release:[VERSION]
}
```
For example:
```js
{
os: "linux",
dist: "Ubuntu",
codename: "precise",
release: "12.04"
}
```
## Disclaimer
Check `os.json` in this repo. Any distribution that *shares* a common resource file with another distrubtion is currently untested. These are the arrays of distrubitons with more than 1 member. If you are using one of these distrubtions, please submit an issue letting me know if it works. If it fails, please post the content of the file.
If you have a distrubtion *not* in `os.json`, please identify your resource file and submit it's name and content along with your distrbution/version in an issue.
Thanks for helping make this tool great.
## Unit Tests
Unit tests stub out the behaviour of the OS files and libraries we depend on to ensure the behaviour of the application is sound. You can run these simply by running `npm test`
## Authors and Contributors
getos has been made possible by these fantastic contributors:
<table><tbody>
<tr><th align="left">Benjamin E. Coe</th><td><a href="https://github.com/bcoe">GitHub/bcoe</a></td><td><a href="http://twitter.com/benjamincoe">Twitter/@benjamincoe</a></td></tr>
<tr><th align="left">Eugene Sharygin</th><td><a href="https://github.com/eush77">GitHub/eush77</a></td><td><a href="http://twitter.com/eush77">Twitter/@eush77</a></td></tr>
<tr><th align="left">David Routhieau</th><td><a href="https://github.com/root-io">GitHub/root-io</a></td><td>unknown</td></tr>
<tr><th align="left">Lawrence</th><td><a href="https://github.com/mindmelting">GitHub/mindmelting</a></td><td><a href="http://twitter.com/mindmelting">Twitter/@mindmelting</a></td></tr>
<tr><th align="left">Roman Jurkov</th><td><a href="https://github.com/winfinit">GitHub/winfinit</a></td><td><a href="http://twitter.com/winfinit">Twitter/@winfinit</a></td></tr>
<tr><th align="left">Rod Vagg</th><td><a href="https://github.com/rvagg">GitHub/rvagg</a></td><td><a href="http://twitter.com/rvagg">Twitter/@rvagg</a></td></tr>
<tr><th align="left">Zeke Sikelianos</th><td><a href="https://github.com/zeke">GitHub/zeke</a></td><td><a href="http://twitter.com/zeke">Twitter/@zeke</a></td></tr>
<tr><th align="left">Alexander</th><td><a href="https://github.com/alex4Zero">GitHub/alex4Zero</a></td><td><a href="http://twitter.com/alex4Zero">Twitter/@alex4Zero</a></td></tr>
</tbody></table>

BIN
CyLukTs/lukan/node_modules/getos/imgs/logo.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

127
CyLukTs/lukan/node_modules/getos/imgs/logo.svg generated vendored Normal file
View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="509.40106"
height="559.78589"
id="svg2"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="New document 1">
<defs
id="defs4">
<inkscape:path-effect
effect="spiro"
id="path-effect3115"
is_visible="true" />
<inkscape:path-effect
effect="spiro"
id="path-effect3111"
is_visible="true" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="176.77841"
inkscape:cy="311.31705"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1362"
inkscape:window-height="764"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
fit-margin-top="20"
fit-margin-left="20"
fit-margin-right="20"
fit-margin-bottom="20" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-117.36125,-80.127747)">
<path
style="fill:#decd87;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 281.10566,557.38743 181.81455,0 16.21774,62.52623 -214.15233,0 z"
id="rect3088-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<rect
style="fill:#e9ddaf;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="rect2987-3"
width="469.40106"
height="469.40106"
x="137.36125"
y="100.12775"
ry="0" />
<rect
style="fill:#1a1a1a;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="rect2987"
width="385.33881"
height="385.33881"
x="179.39238"
y="142.15886"
ry="0" />
<rect
style="fill:none;stroke:#000000;stroke-width:0.92000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3135"
width="30.056622"
height="30.056622"
x="497.4126"
y="533.2384" />
<text
xml:space="preserve"
style="font-size:197.37960815px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:222.00009823%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:FreeSerif;-inkscape-font-specification:FreeSerif"
x="220.26839"
y="358.78876"
id="text3013"
sodipodi:linespacing="222.0001%"><tspan
sodipodi:role="line"
id="tspan3015"
x="220.26839"
y="358.78876"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:222.00009823%;fill:#00ff00;font-family:Fantasque Sans Mono;-inkscape-font-specification:Fantasque Sans Mono"
rotate="0 0 0 0">^ ^</tspan></text>
<text
xml:space="preserve"
style="font-size:197.37960815px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:222.00009823%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:FreeSerif;-inkscape-font-specification:FreeSerif"
x="220.26839"
y="384.78876"
id="text3013-8"
sodipodi:linespacing="222.0001%"><tspan
sodipodi:role="line"
x="220.26839"
y="384.78876"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:222.00009823%;fill:#00ff00;font-family:Fantasque Sans Mono;-inkscape-font-specification:Fantasque Sans Mono"
rotate="0 0 0 0 0 0 0"
id="tspan3959"><tspan
rotate="0 0 0 0"
id="tspan3961"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:222.00009823%;fill:#00ff00;font-family:Fantasque Sans Mono;-inkscape-font-specification:Fantasque Sans Mono"> _ </tspan></tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

154
CyLukTs/lukan/node_modules/getos/index.js generated vendored Normal file
View File

@ -0,0 +1,154 @@
/**
* Things we will need
*/
var async = require('async')
var distros = require('./os.json')
var fs = require('fs')
var os = require('os')
/**
* Begin definition of globals.
*/
var cachedDistro = null // Store result of getLinuxDistro() after first call
/**
* Module definition.
*/
module.exports = function getOs (cb) {
// Node builtin as first line of defense.
var osName = os.platform()
// Linux is a special case.
if (osName === 'linux') return getLinuxDistro(cb)
// Else, node's builtin is acceptable.
return cb(null, { os: osName })
}
/**
* Identify the actual distribution name on a linux box.
*/
function getLinuxDistro (cb) {
/**
* First, we check to see if this function has been called before.
* Since an OS doesn't change during runtime, its safe to cache
* the result and return it for future calls.
*/
if (cachedDistro) return cb(null, cachedDistro)
/**
* We are going to take our list of release files from os.json and
* check to see which one exists. It is safe to assume that no more
* than 1 file in the list from os.json will exist on a distribution.
*/
getReleaseFile(Object.keys(distros), function (e, file) {
if (e) return cb(e)
/**
* Multiple distributions may share the same release file.
* We get our array of candidates and match the format of the release
* files and match them to a potential distribution
*/
var candidates = distros[file]
var os = { os: 'linux', dist: candidates[0] }
fs.readFile(file, 'utf-8', function (e, file) {
if (e) return cb(e)
/**
* If we only know of one distribution that has this file, its
* somewhat safe to assume that it is the distribution we are
* running on.
*/
if (candidates.length === 1) {
return customLogic(os, getName(os.dist), file, function (e, os) {
if (e) return cb(e)
cachedDistro = os
return cb(null, os)
})
}
/**
* First, set everything to lower case to keep inconsistent
* specifications from mucking up our logic.
*/
file = file.toLowerCase()
/**
* Now we need to check all of our potential candidates one by one.
* If their name is in the release file, it is guarenteed to be the
* distribution we are running on. If distributions share the same
* release file, it is reasonably safe to assume they will have the
* distribution name stored in their release file.
*/
async.each(candidates, function (candidate, done) {
var name = getName(candidate)
if (file.indexOf(name) >= 0) {
os.dist = candidate
return customLogic(os, name, file, function (e, augmentedOs) {
if (e) return done(e)
os = augmentedOs
return done()
})
} else {
return done()
}
}, function (e) {
if (e) return cb(e)
cachedDistro = os
return cb(null, os)
})
})
})() // sneaky sneaky.
}
function getName (candidate) {
/**
* We only care about the first word. I.E. for Arch Linux it is safe
* to simply search for "arch". Also note, we force lower case to
* match file.toLowerCase() above.
*/
var index = 0
var name = 'linux'
/**
* Don't include 'linux' when searching since it is too aggressive when
* matching (see #54)
*/
while (name === 'linux') {
name = candidate.split(' ')[index++].toLowerCase()
}
return name
}
/**
* Loads a custom logic module to populate additional distribution information
*/
function customLogic (os, name, file, cb) {
try { require(`./logic/${name}.js`)(os, file, cb) } catch (e) { cb(null, os) }
}
/**
* getReleaseFile() checks an array of filenames and returns the first one it
* finds on the filesystem.
*/
function getReleaseFile (names, cb) {
var index = 0 // Lets keep track of which file we are on.
/**
* checkExists() is a first class function that we are using for recursion.
*/
return function checkExists () {
/**
* Lets get the file metadata off the current file.
*/
fs.stat(names[index], function (e, stat) {
/**
* Now we check if either the file didn't exist, or it is something
* other than a file for some very very bizzar reason.
*/
if (e || !stat.isFile()) {
index++ // If it is not a file, we will check the next one!
if (names.length <= index) { // Unless we are out of files.
return cb(new Error('No unique release file found!')) // Then error.
}
return checkExists() // Re-call this function to check the next file.
}
cb(null, names[index]) // If we found a file, return it!
})
}
}

7
CyLukTs/lukan/node_modules/getos/logic/alpine.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
var releaseRegex = /(.*)/
module.exports = function alpineCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

7
CyLukTs/lukan/node_modules/getos/logic/amazon.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
var releaseRegex = /release (.*)/
module.exports = function amazonCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

1
CyLukTs/lukan/node_modules/getos/logic/arch.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./ubuntu')

10
CyLukTs/lukan/node_modules/getos/logic/centos.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var releaseRegex = /release ([^ ]+)/
var codenameRegex = /\((.*)\)/
module.exports = function centosCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
var codename = file.match(codenameRegex)
if (codename && codename.length === 2) os.codename = codename[1]
cb(null, os)
}

26
CyLukTs/lukan/node_modules/getos/logic/debian.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
var exec = require('child_process').exec
var lsbRelease = /Release:\t(.*)/
var lsbCodename = /Codename:\t(.*)/
var releaseRegex = /(.*)/
module.exports = function (os, file, cb) {
// first try lsb_release
return lsbrelease(os, file, cb)
}
function lsbrelease (os, file, cb) {
exec('lsb_release -a', function (e, stdout, stderr) {
if (e) return releasefile(os, file, cb)
var release = stdout.match(lsbRelease)
if (release && release.length === 2) os.release = release[1]
var codename = stdout.match(lsbCodename)
if (codename && release.length === 2) os.codename = codename[1]
cb(null, os)
})
}
function releasefile (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

10
CyLukTs/lukan/node_modules/getos/logic/fedora.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var releaseRegex = /release (..)/
var codenameRegex = /\((.*)\)/
module.exports = function fedoraCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
var codename = file.match(codenameRegex)
if (codename && codename.length === 2) os.codename = codename[1]
cb(null, os)
}

1
CyLukTs/lukan/node_modules/getos/logic/kde.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./ubuntu')

10
CyLukTs/lukan/node_modules/getos/logic/manjaro.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var releaseRegex = /distrib_release=(.*)/
var codenameRegex = /distrib_codename=(.*)/
module.exports = function ubuntuCustomLogic (os, file, cb) {
var codename = file.match(codenameRegex)
if (codename && codename.length === 2) os.codename = codename[1]
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

1
CyLukTs/lukan/node_modules/getos/logic/mint.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./ubuntu')

10
CyLukTs/lukan/node_modules/getos/logic/raspbian.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var releaseRegex = /VERSION_ID="(.*)"/
var codenameRegex = /VERSION="[0-9] \((.*)\)"/
module.exports = function raspbianCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
var codename = file.match(codenameRegex)
if (codename && codename.length === 2) os.codename = codename[1]
cb(null, os)
}

1
CyLukTs/lukan/node_modules/getos/logic/red.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./centos')

7
CyLukTs/lukan/node_modules/getos/logic/suse.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
var releaseRegex = /VERSION = (.*)\n/
module.exports = function suseCustomLogic (os, file, cb) {
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

10
CyLukTs/lukan/node_modules/getos/logic/ubuntu.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var releaseRegex = /distrib_release=(.*)/
var codenameRegex = /distrib_codename=(.*)/
module.exports = function ubuntuCustomLogic (os, file, cb) {
var codename = file.match(codenameRegex)
if (codename && codename.length === 2) os.codename = codename[1]
var release = file.match(releaseRegex)
if (release && release.length === 2) os.release = release[1]
cb(null, os)
}

1
CyLukTs/lukan/node_modules/getos/logic/zorin.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./ubuntu')

53
CyLukTs/lukan/node_modules/getos/os.json generated vendored Normal file
View File

@ -0,0 +1,53 @@
{
"/etc/fedora-release" : ["Fedora"],
"/etc/redhat-release" : ["RHEL","RHAS","Red Hat Linux","Scientific Linux","ScientificSL","ScientificCERNSLC","ScientificFermiLTS","ScientificSLF","CentOS"],
"/etc/redhat_version" : ["RHEL","RHAS","Red Hat Linux","Scientific Linux","ScientificSL","ScientificCERNSLC","ScientificFermiLTS","ScientificSLF"],
"/etc/SuSE-release": ["SUSE Linux"],
"/etc/lsb-release" : ["Ubuntu","Chakra","IYCC","Linux Mint","elementary OS","Arch Linux","Manjaro Linux", "KDE neon", "Zorin"],
"/etc/debian_version" : ["Debian"],
"/etc/debian_release" : ["Debian"],
"/etc/arch-release" : ["Arch Linux"],
"/etc/NIXOS": ["NixOS"],
"/etc/annvix-release" : ["Annvix"],
"/etc/arklinux-release" : ["Arklinux"],
"/etc/aurox-release" : ["Aurox Linux"],
"/etc/blackcat-release" : ["BlackCat"],
"/etc/cobalt-release" : ["Cobalt"],
"/etc/conectiva-release" : ["Conectiva"],
"/etc/eos-version" : ["FreeEOS"],
"/etc/gentoo-release" : ["Gentoo Linux"],
"/etc/hlfs-release" : ["HLFS"],
"/etc/hlfs_version" : ["HFLS"],
"/etc/immunix-release" : ["Immunix"],
"/knoppix_version" : ["Knoppix"],
"/etc/lfs-release" : ["Linux-From-Scratch"],
"/etc/lfs_version" : ["Linux-From-Scratch"],
"/etc/linuxppc-release" : ["Linux-PPC"],
"/etc/mageia-release" : ["Mageia"],
"/etc/mandriva-release" : ["Mandriva Linux", "Mandrake Linux"],
"/etc/mandakelinux-release" : ["Mandriva Linux", "Mandrake Linux"],
"/etc/mandrake-release" : ["Mandrake", "Mandriva Linux", "Mandrake Linux"],
"/etc/mklinux-release" : ["MkLinux"],
"/etc/nld-release" : ["Novell Linux Desktop"],
"/etc/pld-release" : ["PLD Linux"],
"/etc/rubix-version" : ["Rubix"],
"/etc/slackware-version" : ["Slackware"],
"/etc/slackware-release" : ["Slackware"],
"/etc/e-smith-release" : ["SME Server"],
"/etc/release" : ["Solaris SPARC"],
"/etc/sun-release" : ["Sun JDS"],
"/etc/novell-release" : ["SUSE Linux"],
"/etc/sles-release" : ["SUSE Linux ES9"],
"/etc/synoinfo.conf" : ["Synology"],
"/etc/tinysofa-release" : ["Tiny Sofa"],
"/etc/trustix-release" : ["Trustix"],
"/etc/trustix-version" : ["Trustix"],
"/etc/turbolinux-release" : ["TurboLinux"],
"/etc/ultrapenguin-release" : ["UltraPenguin"],
"/etc/UnitedLinux-release" : ["UnitedLinux"],
"/etc/va-release" : ["VA-Linux/RH-VALE"],
"/etc/yellowdog-release" : ["Yellow Dog"],
"/etc/alpine-release": ["Alpine Linux"],
"/etc/system-release": ["Amazon Linux"],
"/etc/os-release": ["Raspbian"]
}

44
CyLukTs/lukan/node_modules/getos/package.json generated vendored Normal file
View File

@ -0,0 +1,44 @@
{
"name": "getos",
"version": "3.2.1",
"description": "Get the OS/Distribution name of the environment you are working on",
"main": "index.js",
"scripts": {
"test": "node tests/mocktests.js",
"posttest": "standard",
"integration": "node tests/runTest.js",
"standard-fix": "standard --fix"
},
"repository": {
"type": "git",
"url": "https://github.com/retrohacker/getos.git"
},
"keywords": [
"OS",
"Distribution",
"Platform",
"Version"
],
"author": "william.jblankenship@gmail.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/retrohacker/getos/issues"
},
"homepage": "https://github.com/retrohacker/getos",
"devDependencies": {
"cli-color": "^2.0.0",
"execSync": "^1.0.2",
"standard": "^14.3.1",
"tape": "^4.13.2"
},
"dependencies": {
"async": "^3.2.0"
},
"contributors": [
{
"name": "Benjamin E. Coe",
"email": "bencoe@gmail.com",
"url": "https://github.com/bcoe"
}
]
}

4
CyLukTs/lukan/node_modules/getos/test.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
require('./index.js')(function (e, os) {
if (e) return console.log(e)
return console.log(JSON.stringify(os))
})

View File

@ -0,0 +1,11 @@
FROM alpine:3.3
MAINTAINER David Routhieau "rootio@protonmail.com"
RUN apk add --update --no-cache \
nodejs
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node", "test.js"]

View File

@ -0,0 +1,20 @@
FROM debian:7.3
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
# Setup NodeSource Official PPA
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

View File

@ -0,0 +1,20 @@
FROM debian:7.4
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
# Setup NodeSource Official PPA
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

View File

@ -0,0 +1,20 @@
FROM debian:7.5
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
# Setup NodeSource Official PPA
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

View File

@ -0,0 +1,20 @@
FROM debian:7.6
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
# Setup NodeSource Official PPA
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

View File

@ -0,0 +1,9 @@
FROM fedora:20
MAINTAINER William Blankenship <william.jblankenship@gmail.com>
RUN yum install -y nodejs npm
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

23
CyLukTs/lukan/node_modules/getos/tests/mockdata.json generated vendored Normal file
View File

@ -0,0 +1,23 @@
[
{ "desc": "OS X", "platform": "darwin", "expected": { "os": "darwin" } }
, { "desc": "Windows", "platform": "win32", "expected": { "os": "win32" } }
, { "desc": "Ubuntu 14.10", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=14.10\nDISTRIB_CODENAME=utopic\nDISTRIB_DESCRIPTION=\"Ubuntu 14.10\"\n" }, "expected": { "codename": "utopic", "dist": "Ubuntu", "os": "linux", "release": "14.10" } }
, { "desc": "Ubuntu 14.04", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=14.04\nDISTRIB_CODENAME=trusty\nDISTRIB_DESCRIPTION=\"Ubuntu 14.04.2 LTS\"\n" }, "expected": { "codename": "trusty", "dist": "Ubuntu", "os": "linux", "release": "14.04" } }
, { "desc": "Ubuntu 12.04", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=12.04\nDISTRIB_CODENAME=precise\nDISTRIB_DESCRIPTION=\"Ubuntu 12.04.5 LTS\"\n" }, "expected": { "codename": "precise", "dist": "Ubuntu", "os": "linux", "release": "12.04" } }
, { "desc": "Fedora 21", "platform": "linux", "file": { "/etc/fedora-release": "Fedora release 21 (Twenty One)\n" }, "expected": { "codename": "Twenty One", "dist": "Fedora", "os": "linux", "release": "21" } }
, { "desc": "CentOS 5.11", "platform": "linux", "file": { "/etc/redhat-release": "CentOS release 5.11 (Final)\n" }, "expected": { "codename": "final", "dist": "CentOS", "os": "linux", "release": "5.11" } }
, { "desc": "CentOS 6.6", "platform": "linux", "file": { "/etc/redhat-release": "CentOS release 6.6 (Final)\n" }, "expected": { "codename": "final", "dist": "CentOS", "os": "linux", "release": "6.6" } }
, { "desc": "CentOS 7.1", "platform": "linux", "file": { "/etc/redhat-release": "CentOS Linux release 7.1.1503 (Core)\n" }, "expected": { "codename": "core", "dist": "CentOS", "os": "linux", "release": "7.1.1503" } }
, { "desc": "RHEL 6.5", "platform": "linux", "file": { "/etc/redhat-release": "Red Hat Enterprise Linux Server release 6.5 (Santiago)\n" }, "expected": { "codename": "santiago", "dist": "Red Hat Linux", "os": "linux", "release": "6.5" } }
, { "desc": "RHEL 6.6", "platform": "linux", "file": { "/etc/redhat-release": "Red Hat Enterprise Linux Server release 6.6 (Santiago)\n" }, "expected": { "codename": "santiago", "dist": "Red Hat Linux", "os": "linux", "release": "6.6" } }
, { "desc": "RHEL 7.0", "platform": "linux", "file": { "/etc/redhat-release": "Red Hat Enterprise Linux Server release 7.0 (Maipo)\n" }, "expected": { "codename": "maipo", "dist": "Red Hat Linux", "os": "linux", "release": "7.0" } }
, { "desc": "SUSE Linux", "platform": "linux", "file": { "/etc/SuSE-release": "SUSE Linux Enterprise Server 11 (x86_64)\nVERSION = 11\nPATCHLEVEL = 4\n" }, "expected": { "dist": "SUSE Linux", "os": "linux", "release": "11" } }
, { "desc": "Alpine Linux", "platform": "linux", "file": { "/etc/alpine-release": "3.3\n", "/etc/os-release": "NAME=\"Alpine Linux\"\nID=alpine\nVERSION_ID=3.9.2\nPRETTY_NAME=\"Alpine Linux v3.9\"\nHOME_URL=\"https://alpinelinux.org/\"\nBUG_REPORT_URL=\"https://bugs.alpinelinux.org/\"\n" }, "expected": { "dist": "Alpine Linux", "os": "linux", "release": "3.3" } }
, { "desc": "Amazon Linux", "platform": "linux", "file": { "/etc/system-release": "Amazon Linux AMI release 2016.03"}, "expected": {"dist": "Amazon Linux", "os": "linux", "release": "2016.03"}}
, { "desc": "Arch Linux", "platform": "linux", "file": { "/etc/lsb-release": "LSB_VERSION=1.4\nDISTRIB_ID=Arch\nDISTRIB_RELEASE=rolling\nDISTRIB_DESCRIPTION=\"Arch Linux\""}, "expected": {"dist": "Arch Linux", "os": "linux", "release": "rolling"}}
, { "desc": "Linux Mint", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=LinuxMint\nDISTRIB_RELEASE=18\nDISTRIB_CODENAME=sarah\nDISTRIB_DESCRIPTION=\"Linux Mint 18 Sarah\""}, "expected": {"dist": "Linux Mint", "os": "linux", "codename": "sarah", "release": "18"}}
, { "desc": "Raspbian 8", "platform": "linux", "file": { "/etc/os-release": "PRETTY_NAME=\"Raspbian GNU/Linux 8 (jessie)\"\nNAME=\"Raspbian GNU/Linux\"\nVERSION_ID=\"8\"\nVERSION=\"8 (jessie)\"\nID=raspbian\nHOME_URL=\"http://www.raspbian.org/\"\nSUPPORT_URL=\"http://www.raspbian.org/RaspbianForums\"\nBUG_REPORT_URL=\"http://www.raspbian.org/RaspbianBugs\"" }, "expected": { "codename": "jessie", "dist": "Raspbian", "os": "linux", "release": "8" } }
, { "desc": "Manjaro Linux", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=ManjaroLinux\nDISTRIB_RELEASE=17.1.10\nDISTRIB_CODENAME=Hakoila\nDISTRIB_DESCRIPTION=\"Manjaro Linux\"" }, "expected": { "codename": "hakoila", "dist": "Manjaro Linux", "os": "linux", "release": "17.1.10" } }
, { "desc": "KDE neon", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=neon\nDISTRIB_RELEASE=18.04\nDISTRIB_CODENAME=bionic\nDISTRIB_DESCRIPTION=\"KDE neon User Edition 5.16\"" }, "expected": { "codename": "bionic", "dist": "KDE neon", "os": "linux", "release": "18.04" } }
, { "desc": "NixOS", "platform": "linux", "file": { "/etc/NIXOS": " " }, "expected": { "dist": "NixOS", "os": "linux" } }
]

40
CyLukTs/lukan/node_modules/getos/tests/mocktests.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
var test = require('tape')
var fs = require('fs')
var os = require('os')
var mockdata = require('./mockdata')
var currentData
os.platform = function () {
return currentData.platform
}
fs.stat = function (file, callback) {
process.nextTick(function () {
if (!currentData.file[file]) { return callback(new Error()) }
callback(null, { isFile: function () { return true } })
})
}
fs.readFile = function (file, enc, callback) {
process.nextTick(function () {
if (!currentData.file[file]) { return callback(new Error()) }
callback(null, currentData.file[file])
})
}
mockdata.forEach(function (data) {
test('test ' + data.desc, function (t) {
// reload each time to avoid internal caching
delete require.cache[require.resolve('../')]
var getos = require('../')
currentData = data
getos(function (err, os) {
t.error(err, 'no error')
t.deepEqual(os, data.expected, 'correct os data')
t.end()
})
})
})

79
CyLukTs/lukan/node_modules/getos/tests/runTest.js generated vendored Normal file
View File

@ -0,0 +1,79 @@
var color = require('cli-color')
var execSync = require('child_process').execSync || require('execSync').exec
var fs = require('fs')
var path = require('path')
/**
* So most of this stuff will be sync, because we are moving
* files around building docker images, etc. These all have
* to be done in a specific order or chaos ensues
*/
var cwd = path.join(process.cwd(), 'tests')
process.stdout.write('Fetching Distributions... ')
var distros = fs.readdirSync(cwd)
var failed = []
process.stdout.write('[' + color.green('OK!') + ']\n')
distros.forEach(function (v1) {
if (!fs.statSync(path.join(cwd, v1)).isDirectory()) return
process.stdout.write('Fetching versions of ' + capitalize(v1) + '... ')
var versions = fs.readdirSync(path.join(cwd, v1))
process.stdout.write('[' + color.green('OK!') + ']\n')
versions.forEach(function (v2) {
if (!fs.statSync(path.join(cwd, v1, v2)).isDirectory()) return
// If Dockerfile already exists, delete it.
if (fs.existsSync(path.join(process.cwd(), 'Dockerfile'))) { fs.unlinkSync(path.join(process.cwd(), 'Dockerfile')) }
// Move the dockerfile to the base of our repo
fs.linkSync(path.join(cwd, v1, v2, 'Dockerfile'), path.join(process.cwd(), 'Dockerfile'))
// Build the docker image using the dockerfile
process.stdout.write('Building version ' + v2 + ' of ' + capitalize(v1) + '... ')
try {
var dockerResult = execSync('docker build -t "getos:' + v1 + v2 + '" .', { stdio: [] })
} catch (e) {
dockerResult = dockerResult || {}
dockerResult.code = e
}
if (dockerResult.code && dockerResult.code !== 0) {
failed.push(dockerResult)
process.stdout.write('[' + color.red('FAILED!') + ']\n')
} else {
process.stdout.write('[' + color.green('OK!') + ']\n')
process.stdout.write('Running container... ')
// Show output from distribution
try {
var nodeResult = execSync('docker run -d getos:' + v1 + v2, { stdio: [] })
} catch (e) {
nodeResult = nodeResult || {}
nodeResult.code = e
}
if (nodeResult.code && nodeResult.code !== 0) {
failed.push(nodeResult)
process.stdout.write('[' + color.red('FAILED!') + ']\n')
} else {
try {
var dockerLog = execSync('sleep 2s && docker logs ' + (nodeResult.stdout || nodeResult.toString()), { stdio: [] })
} catch (e) {
dockerLog = dockerLog || {}
dockerLog.code = e
}
if (dockerLog.code && dockerLog.code !== 0) {
failed.push(dockerLog)
process.stdout.write('[' + color.red('FAILED!') + ']\n')
} else {
process.stdout.write('[' + color.green('OK!') + ']\n')
process.stdout.write('Output from version ' + v2 + ' of ' + capitalize(v1) + ': \n')
process.stdout.write(dockerLog.stdout || dockerLog.toString())
}
}
}
// Delete the dockerfile
fs.unlinkSync(path.join(process.cwd(), 'Dockerfile'))
})
})
if (failed.length > 0) {
fs.writeFileSync('tests.log', JSON.stringify(failed, null, ' '))
}
function capitalize (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}

View File

@ -0,0 +1,18 @@
FROM ubuntu:13.10
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]

View File

@ -0,0 +1,18 @@
FROM ubuntu:14.04
RUN apt-get update && \
apt-get install -y --force-yes \
curl \
apt-transport-https \
lsb-release \
build-essential \
python-all
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get update
RUN apt-get install nodejs -y --force-yes
ADD . /usr/src/
WORKDIR /usr/src/
CMD ["node","test.js"]