Updated the Survey.
This commit is contained in:
parent
f59686eae0
commit
6d3ba1a714
1203 changed files with 140782 additions and 5 deletions
109
node_modules/configstore/index.js
generated
vendored
Normal file
109
node_modules/configstore/index.js
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('graceful-fs');
|
||||
const makeDir = require('make-dir');
|
||||
const xdgBasedir = require('xdg-basedir');
|
||||
const writeFileAtomic = require('write-file-atomic');
|
||||
const dotProp = require('dot-prop');
|
||||
const uniqueString = require('unique-string');
|
||||
|
||||
const configDirectory = xdgBasedir.config || path.join(os.tmpdir(), uniqueString());
|
||||
const permissionError = 'You don\'t have access to this file.';
|
||||
const makeDirOptions = {mode: 0o0700};
|
||||
const writeFileOptions = {mode: 0o0600};
|
||||
|
||||
class Configstore {
|
||||
constructor(id, defaults, options = {}) {
|
||||
const pathPrefix = options.globalConfigPath ?
|
||||
path.join(id, 'config.json') :
|
||||
path.join('configstore', `${id}.json`);
|
||||
|
||||
this.path = options.configPath || path.join(configDirectory, pathPrefix);
|
||||
|
||||
if (defaults) {
|
||||
this.all = {
|
||||
...defaults,
|
||||
...this.all
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
get all() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(this.path, 'utf8'));
|
||||
} catch (error) {
|
||||
// Create directory if it doesn't exist
|
||||
if (error.code === 'ENOENT') {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Improve the message of permission errors
|
||||
if (error.code === 'EACCES') {
|
||||
error.message = `${error.message}\n${permissionError}\n`;
|
||||
}
|
||||
|
||||
// Empty the file if it encounters invalid JSON
|
||||
if (error.name === 'SyntaxError') {
|
||||
writeFileAtomic.sync(this.path, '', writeFileOptions);
|
||||
return {};
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
set all(value) {
|
||||
try {
|
||||
// Make sure the folder exists as it could have been deleted in the meantime
|
||||
makeDir.sync(path.dirname(this.path), makeDirOptions);
|
||||
|
||||
writeFileAtomic.sync(this.path, JSON.stringify(value, undefined, '\t'), writeFileOptions);
|
||||
} catch (error) {
|
||||
// Improve the message of permission errors
|
||||
if (error.code === 'EACCES') {
|
||||
error.message = `${error.message}\n${permissionError}\n`;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
get size() {
|
||||
return Object.keys(this.all || {}).length;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return dotProp.get(this.all, key);
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
const config = this.all;
|
||||
|
||||
if (arguments.length === 1) {
|
||||
for (const k of Object.keys(key)) {
|
||||
dotProp.set(config, k, key[k]);
|
||||
}
|
||||
} else {
|
||||
dotProp.set(config, key, value);
|
||||
}
|
||||
|
||||
this.all = config;
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return dotProp.has(this.all, key);
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
const config = this.all;
|
||||
dotProp.delete(config, key);
|
||||
this.all = config;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.all = {};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Configstore;
|
25
node_modules/configstore/license
generated
vendored
Normal file
25
node_modules/configstore/license
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) Google
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
78
node_modules/configstore/package.json
generated
vendored
Normal file
78
node_modules/configstore/package.json
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"_from": "configstore@^5.0.1",
|
||||
"_id": "configstore@5.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==",
|
||||
"_location": "/configstore",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "configstore@^5.0.1",
|
||||
"name": "configstore",
|
||||
"escapedName": "configstore",
|
||||
"rawSpec": "^5.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/update-notifier"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz",
|
||||
"_shasum": "d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96",
|
||||
"_spec": "configstore@^5.0.1",
|
||||
"_where": "D:\\Documents\\UniWork\\Year 4\\Semester 2\\SEG3125\\Labs\\Lab 6\\Survey_Analysis\\node_modules\\update-notifier",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/yeoman/configstore/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"dot-prop": "^5.2.0",
|
||||
"graceful-fs": "^4.1.2",
|
||||
"make-dir": "^3.0.0",
|
||||
"unique-string": "^2.0.0",
|
||||
"write-file-atomic": "^3.0.0",
|
||||
"xdg-basedir": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Easily load and save config without having to think about where and how",
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/yeoman/configstore#readme",
|
||||
"keywords": [
|
||||
"config",
|
||||
"store",
|
||||
"storage",
|
||||
"configuration",
|
||||
"settings",
|
||||
"preferences",
|
||||
"json",
|
||||
"data",
|
||||
"persist",
|
||||
"persistent",
|
||||
"save"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"name": "configstore",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/yeoman/configstore.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "5.0.1"
|
||||
}
|
141
node_modules/configstore/readme.md
generated
vendored
Normal file
141
node_modules/configstore/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
# configstore [](https://travis-ci.org/yeoman/configstore)
|
||||
|
||||
> Easily load and persist config without having to think about where and how
|
||||
|
||||
The config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
|
||||
Example: `~/.config/configstore/some-id.json`
|
||||
|
||||
*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*<br>
|
||||
*And check out [`conf`](https://github.com/sindresorhus/conf) for an updated approach to this concept.*
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install configstore
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const Configstore = require('configstore');
|
||||
const packageJson = require('./package.json');
|
||||
|
||||
// Create a Configstore instance
|
||||
const config = new Configstore(packageJson.name, {foo: 'bar'});
|
||||
|
||||
console.log(config.get('foo'));
|
||||
//=> 'bar'
|
||||
|
||||
config.set('awesome', true);
|
||||
console.log(config.get('awesome'));
|
||||
//=> true
|
||||
|
||||
// Use dot-notation to access nested properties
|
||||
config.set('bar.baz', true);
|
||||
console.log(config.get('bar'));
|
||||
//=> {baz: true}
|
||||
|
||||
config.delete('awesome');
|
||||
console.log(config.get('awesome'));
|
||||
//=> undefined
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### Configstore(packageName, defaults?, options?)
|
||||
|
||||
Returns a new instance.
|
||||
|
||||
#### packageName
|
||||
|
||||
Type: `string`
|
||||
|
||||
Name of your package.
|
||||
|
||||
#### defaults
|
||||
|
||||
Type: `object`
|
||||
|
||||
Default config.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### globalConfigPath
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
|
||||
|
||||
##### configPath
|
||||
|
||||
Type: `string`<br>
|
||||
Default: Automatic
|
||||
|
||||
**Please don't use this option unless absolutely necessary and you know what you're doing.**
|
||||
|
||||
Set the path of the config file. Overrides the `packageName` and `globalConfigPath` options.
|
||||
|
||||
### Instance
|
||||
|
||||
You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.
|
||||
|
||||
### .set(key, value)
|
||||
|
||||
Set an item.
|
||||
|
||||
### .set(object)
|
||||
|
||||
Set multiple items at once.
|
||||
|
||||
### .get(key)
|
||||
|
||||
Get an item.
|
||||
|
||||
### .has(key)
|
||||
|
||||
Check if an item exists.
|
||||
|
||||
### .delete(key)
|
||||
|
||||
Delete an item.
|
||||
|
||||
### .clear()
|
||||
|
||||
Delete all items.
|
||||
|
||||
### .size
|
||||
|
||||
Get the item count.
|
||||
|
||||
### .path
|
||||
|
||||
Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
|
||||
|
||||
### .all
|
||||
|
||||
Get all the config as an object or replace the current config with an object:
|
||||
|
||||
```js
|
||||
config.all = {
|
||||
hello: 'world'
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-configstore?utm_source=npm-configstore&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue