Browse Source

Initial commit

Add files from pridepack.
master
TheoryOfNekomata 1 year ago
commit
cd5e243bfd
13 changed files with 3354 additions and 0 deletions
  1. +9
    -0
      .eslintrc
  2. +107
    -0
      .gitignore
  3. +7
    -0
      LICENSE
  4. +84
    -0
      package.json
  5. +3
    -0
      pridepack.json
  6. +35
    -0
      src/git.ts
  7. +1
    -0
      src/index.ts
  8. +15
    -0
      src/utils/fs.ts
  9. +34
    -0
      src/utils/process.ts
  10. +8
    -0
      test/index.test.ts
  11. +21
    -0
      tsconfig.eslint.json
  12. +21
    -0
      tsconfig.json
  13. +3009
    -0
      yarn.lock

+ 9
- 0
.eslintrc View File

@@ -0,0 +1,9 @@
{
"root": true,
"extends": [
"lxsmnsyc/typescript"
],
"parserOptions": {
"project": "./tsconfig.eslint.json"
}
}

+ 107
- 0
.gitignore View File

@@ -0,0 +1,107 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.production
.env.development

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.npmrc

+ 7
- 0
LICENSE View File

@@ -0,0 +1,7 @@
MIT License Copyright (c) 2022 TheoryOfNekomata <allan.crisostomo@outlook.com>

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 (including the next paragraph) 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.

+ 84
- 0
package.json View File

@@ -0,0 +1,84 @@
{
"name": "core",
"version": "0.0.0",
"types": "dist/types/index.d.ts",
"main": "dist/cjs/production/index.js",
"module": "dist/esm/production/index.js",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.js",
"import": "./dist/esm/development/index.js"
},
"require": "./dist/cjs/production/index.js",
"import": "./dist/esm/production/index.js",
"types": "./dist/types/index.d.ts"
},
"./dev": {
"production": {
"require": "./dist/cjs/production/index.js",
"import": "./dist/esm/production/index.js"
},
"require": "./dist/cjs/development/index.js",
"import": "./dist/esm/development/index.js",
"types": "./dist/types/index.d.ts"
},
"./esm": {
"development": "./dist/esm/development/index.js",
"production": "./dist/esm/production/index.js",
"default": "./dist/esm/production/index.js",
"types": "./dist/types/index.d.ts"
},
"./cjs": {
"development": "./dist/cjs/development/index.js",
"production": "./dist/cjs/production/index.js",
"default": "./dist/cjs/production/index.js",
"types": "./dist/types/index.d.ts"
}
},
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack"
],
"devDependencies": {
"@types/node": "^17.0.25",
"eslint": "^8.13.0",
"eslint-config-lxsmnsyc": "^0.4.0",
"pridepack": "1.1.1",
"tslib": "^2.4.0",
"typescript": "^4.6.3",
"vitest": "^0.9.4"
},
"scripts": {
"prepublishOnly": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch",
"start": "node dist/cjs/production",
"dev": "pridepack dev",
"test": "vitest"
},
"private": false,
"description": "Core logic for Code.",
"repository": {
"url": "https://code.modal.sh/modal/code-sdk",
"type": "git"
},
"homepage": "https://code.modal.sh/modal/code-sdk",
"bugs": {
"url": "https://code.modal.sh/modal/code-sdk/issues"
},
"author": "TheoryOfNekomata <allan.crisostomo@outlook.com>",
"publishConfig": {
"access": "public"
}
}

+ 3
- 0
pridepack.json View File

@@ -0,0 +1,3 @@
{
"target": "es2017"
}

+ 35
- 0
src/git.ts View File

@@ -0,0 +1,35 @@
import {spawn} from './utils/process';
import {mkdirp} from './utils/fs';

export enum RepoVisibility {
PRIVATE,
INTERNAL,
PUBLIC,
}

export enum OwnerType {
USER,
ORG,
}

type Owner = {
name: string,
type: OwnerType,
}

type CreateOptions = {
name: string,
owner: Owner,
visibility: RepoVisibility,
}

const OWNER_TYPE_DIR_NAMES: Record<OwnerType, string> = {
[OwnerType.USER]: 'users',
[OwnerType.ORG]: 'orgs',
}

export const create = async (options: CreateOptions) => {
const repoBasePath = `${OWNER_TYPE_DIR_NAMES[options.owner.type]}/${options.owner.name}/${options.name}`;
await mkdirp(repoBasePath);
return spawn(repoBasePath, 'git', ['init', '--bare']);
}

+ 1
- 0
src/index.ts View File

@@ -0,0 +1 @@
export * as git from './git';

+ 15
- 0
src/utils/fs.ts View File

@@ -0,0 +1,15 @@
import * as fs from 'fs/promises';
import * as p from 'path';

export const mkdirp = (path: string) => {
const pathFragments = path.replaceAll('\\', '/').split('/');
const directoriesToCheck = pathFragments.reduce(
(theDirectories, fragment, i) => [
...theDirectories,
theDirectories.length > 0 ? p.join(theDirectories[i - 1], fragment) : fragment,
],
[] as string[],
)

return Promise.allSettled(directoriesToCheck.map((d) => fs.mkdir(d)));
}

+ 34
- 0
src/utils/process.ts View File

@@ -0,0 +1,34 @@
import * as childProcess from 'child_process';

export const spawn = (
cwd: string,
command: string,
args: string[],
parentProcess = process,
) => new Promise<string>((resolve, reject) => {
let stdout = '';
let stderr = '';

const theChildProcess = childProcess.spawn(command, args, {
cwd,
});

theChildProcess.stdout.on('data', (data) => {
parentProcess.stdout.write(data);
stdout += data;
});

theChildProcess.stderr.on('data', (data) => {
parentProcess.stderr.write(data);
stderr += data;
});

theChildProcess.on('close', (code) => {
if (code !== 0) {
reject(new Error(stderr));
return;
}

resolve(stdout);
})
})

+ 8
- 0
test/index.test.ts View File

@@ -0,0 +1,8 @@
import { describe, it, expect } from 'vitest';
import add from '../src';

describe('blah', () => {
it('works', () => {
expect(add(1, 1)).toEqual(2);
});
});

+ 21
- 0
tsconfig.eslint.json View File

@@ -0,0 +1,21 @@
{
"exclude": ["node_modules"],
"include": ["src", "types", "test"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017"
}
}

+ 21
- 0
tsconfig.json View File

@@ -0,0 +1,21 @@
{
"exclude": ["node_modules"],
"include": ["src", "types"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017"
}
}

+ 3009
- 0
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save