New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

git-pwa

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-pwa - npm Package Compare versions

Comparing version

to
1.0.7

32

git.js

@@ -6,28 +6,20 @@ #!/usr/bin/env node

import ini from 'ini';
import fs, { read } from 'fs';
import fs from 'fs';
import 'dotenv/config';
async function main() {
const oLoader = new GitLoader();
const aIgnoreCommands = ['clone', 'init', 'status'];
const aIgnoreCommands = ['init', 'status'];
if (!aIgnoreCommands.includes(process.argv[2]) && !oLoader.config.user) {
oLoader.config.user = {};
oLoader.config.user.name = await question('Enter your user name: ');
oLoader.config.user.email = await question('Enter your email: ');
fs.writeFileSync(
`${oLoader.base.dir}/${oLoader.base.gitdir}/config`,
ini.stringify(oLoader.config)
);
if (!aIgnoreCommands.includes(process.argv[2]) && !process.env['USER_NAME']) {
process.env['USER_NAME'] = await question('Enter your user name: ');
process.env['USER_EMAIL'] = await question('Enter your email: ');
fs.appendFileSync('.env', `USER_NAME="${process.env['USER_NAME']}"\n`);
fs.appendFileSync('.env', `USER_EMAIL="${process.env['USER_EMAIL']}"\n`);
}
if (
!aIgnoreCommands.includes(process.argv[2]) &&
!oLoader.config.user.token
) {
oLoader.config.user.token = await question('Enter your token: ');
fs.writeFileSync(
`${oLoader.base.dir}/${oLoader.base.gitdir}/config`,
ini.stringify(oLoader.config)
);
if (!aIgnoreCommands.includes(process.argv[2]) && !process.env['USER_TOKEN']) {
process.env['USER_TOKEN'] = await question('Enter your token: ');
fs.appendFileSync('.env', `USER_TOKEN="${process.env['USER_TOKEN']}"\n`);
}
const oLoader = new GitLoader();
const spinner = ora(`running git ${process.argv[2] || ''} ... `).start();

@@ -34,0 +26,0 @@ try{

{
"name": "git-pwa",
"version": "1.0.6",
"version": "1.0.7",
"description": "git to use in a progressive web app",

@@ -9,3 +9,8 @@ "bin": {

},
"files": ["dist", "src/GitLoader.js", "README.md", "src/question.js"],
"files": [
"dist",
"src/GitLoader.js",
"README.md",
"src/question.js"
],
"main": "./dist/git-pwa.umd.js",

@@ -27,3 +32,6 @@ "module": "./dist/git-pwa.es.js",

},
"keywords": ["pwa", "git"],
"keywords": [
"pwa",
"git"
],
"author": "Rich Hildred",

@@ -37,2 +45,3 @@ "license": "MIT",

"dependencies": {
"dotenv": "^16.3.1",
"git-pwa": "^1.0.2",

@@ -39,0 +48,0 @@ "ini": "^4.1.0",

@@ -22,2 +22,4 @@ import fs from 'fs';

};
this.base.USER_TOKEN = process.env['USER_TOKEN'];
this.base.onAuth = () => ({ username: this.base.USER_TOKEN });
try {

@@ -27,3 +29,2 @@ this.config = ini.parse(

);
this.base.onAuth = () => ({ username: this.config.user.token });
} catch {

@@ -37,66 +38,2 @@ this.config = {};

}
match(first, second) {
// If we reach at the end of both strings,
// we are done
if (first.length == 0 && second.length == 0) return true;
// Make sure that the characters after '*'
// are present in second string.
// This function assumes that the first
// string will not contain two consecutive '*'
if (first.length > 1 && first[0] == '*' && second.length == 0) return false;
// If the first string contains '?',
// or current characters of both strings match
if (
(first.length > 1 && first[0] == '?') ||
(first.length != 0 && second.length != 0 && first[0] == second[0])
)
return this.match(first.substring(1), second.substring(1));
// If there is *, then there are two possibilities
// a) We consider current character of second string
// b) We ignore current character of second string.
if (first.length > 0 && first[0] == '*')
return (
this.match(first.substring(1), second) ||
this.match(first, second.substring(1))
);
return false;
}
isInGitignore(second) {
for (let first of this.gitignore) {
first = first.replace(/\/$/, '');
if (this.match(first, second)) {
return true;
}
}
return false;
}
async walk(sDir, oConfig, filelist = []) {
const files = await fsp.readdir(sDir);
for (const file of files) {
if (this.isInGitignore(file)) continue;
const filepath = path.join(sDir, file);
const stat = await fsp.stat(filepath);
if (stat && stat.isDirectory()) {
filelist = await this.walk(filepath, oConfig, filelist);
} else {
let filepath = file;
if (sDir != '.') {
filepath = `${sDir}/${file}`;
}
oConfig.filepath = filepath;
const sStatus = await git.status(oConfig);
if (sStatus != 'unmodified') {
filelist.push(`${filepath} ${sStatus}`);
}
}
}
return filelist;
}
async runCommand() {

@@ -129,2 +66,3 @@ try {

message: this.argv.m,
author: {name: process.env['USER_NAME'], email: process.env['USER_EMAIL']}
},

@@ -148,5 +86,24 @@ addRemote: {

this.command = {
deploy: (oConfig) => {
// see https://isomorphic-git.org/docs/en/snippets
return 'deployed';
add: async (oConfig) => {
let filelist = ['', `on branch ${this.base.ref}`];
if(oConfig.filepath == "." || oConfig.filepath == "all"){
const aFiles = await git.statusMatrix(oConfig);
for(const aFile of aFiles){
if(aFile[1] == 1 && aFile[2] == 1 && aFile[3] == 1){
//unchanged
}else{
oConfig.filepath = aFile[0];
await git.add(oConfig);
filelist.push(`added ${aFile[0]}`);
}
}
if(filelist.length <= 2){
filelist.push("nothing to add");
}
}else{
await git.add(oConfig);
filelist.push(`added ${oConfig.filepath}`);
}
return(filelist.join("\n"));
},

@@ -174,12 +131,10 @@ push: async (oConfig) => {

let filelist = ['', `on branch ${this.base.ref}`];
try {
this.gitignore = fs
.readFileSync('.gitignore')
.toString()
.split('\n');
} catch {
this.gitignore = [];
const aFiles = await git.statusMatrix(oConfig);
for(const aFile of aFiles){
if(aFile[1] == 1 && aFile[2] == 1 && aFile[3] == 1){
// file is unchanged
}else{
filelist.push(`${aFile[0]}: locally modified`);
}
}
this.gitignore.unshift('.git');
await this.walk('.', oConfig, filelist);
if (filelist.length > 2) {

@@ -186,0 +141,0 @@ return filelist.join('\n');