Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deps #50

Merged
merged 20 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"rome.rome"
"biomejs.biome"
]
}
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.2.2.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "5.0.2-sdk",
"version": "5.2.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compressionLevel: mixed

enableGlobalCache: false

yarnPath: .yarn/releases/yarn-4.2.2.cjs
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Araxeus
Copyright (c) 2024 Araxeus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 12 additions & 3 deletions rome.json → biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"files": {
"ignore": [
"./.pnp.*",
"./.yarn/*",
"./dist/*",
"./vendor/*",
"./lib/auth.js"
Expand All @@ -12,10 +14,15 @@
"quoteStyle": "single"
}
},
"json": {
"formatter": {
"enabled": false
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentSize": 4,
"indentWidth": 4,
"ignore": [
"*.json"
]
Expand All @@ -28,9 +35,11 @@
"noUndeclaredVariables": "error",
"noUnusedVariables": "error"
},
"nursery": {
"recommended": true,
"style": {
"noParameterAssign": "off"
},
"nursery": {
"recommended": true
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type { FilesArray, VendorsOptions } from './lib/types.js';

import { Command } from '@commander-js/extra-typings';

import { install, sync, uninstall } from './lib/commands.js';
import { getConfig, setRunOptions } from './lib/config.js';
import { findRepoUrl, login } from './lib/github.js';
import {
assert,
getPackageJson,
isGitHubUrl,
ownerAndNameFromRepoUrl,
} from './lib/utils.js';
import { sync, install, uninstall } from './lib/commands.js';
import { getConfig, setRunOptions } from './lib/config.js';
import { findRepoUrl, login } from './lib/github.js';

let vendorOptions: VendorsOptions;

Expand Down Expand Up @@ -44,9 +44,9 @@ const updateCmd = new Command('update')
if (names.length === 0) {
upgradeAll(pr);
} else {
names.forEach((name: string) => {
for (const name of names) {
upgradeOne(name);
});
}
}
})
.summary('Update outdated dependencies')
Expand Down Expand Up @@ -148,9 +148,9 @@ const uninstallCmd = new Command('uninstall')
.action((names) => {
assert(names.length > 0, 'No package names provided');

names.forEach((name: string) => {
for (const name of names) {
uninstallOne(name);
});
}
})
.summary('Uninstall dependencies')
.description('Uninstall all/selected dependencies')
Expand Down
12 changes: 6 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
export * from './lib/commands.js';
export * from './lib/config.js';
export * from './lib/github.js';
export * from './lib/utils.js';
export type {
Repository,
ConfigFile,
ConfigFileSettings,
VendorConfig,
FileInputOutput,
FilesArray,
Lockfile,
VendorLock,
VendorLockFiles,
VendorLockFile,
Repository,
VendorConfig,
VendorDependencies,
VendorDependency,
VendorLock,
VendorLockFile,
VendorLockFiles,
VendorsOptions,
} from './lib/types.d.ts';
export * from './lib/utils.js';

// Soon™:
// > add a --config option to specify a folder where to look for the config file
Expand Down
36 changes: 19 additions & 17 deletions lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ import type {
VendorsOptions,
} from './types.js';

import path from 'node:path';
import fs from 'node:fs/promises';
import { existsSync } from 'node:fs';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';

import { unarchive } from 'unarchive';

import { getRunOptions, writeConfig } from './config.js';
import github from './github.js';
import {
ownerAndNameFromRepoUrl,
writeLockfile,
assert,
checkIfNeedsUpdate,
configFilesToVendorlockFiles,
deleteFileAndEmptyFolders,
error,
info,
success,
validateVendorDependency,
flatFiles,
getDependencyFolder,
getFilesFromLockfile,
green,
info,
ownerAndNameFromRepoUrl,
random,
readLockfile,
flatFiles,
deleteFileAndEmptyFolders,
readableToFile,
configFilesToVendorlockFiles,
replaceVersion,
random,
assert,
red,
green,
replaceVersion,
success,
validateVendorDependency,
writeLockfile,
} from './utils.js';

export async function sync(
Expand Down Expand Up @@ -287,7 +287,9 @@ export async function install({
if (input.startsWith('{release}/')) {
releaseFiles.push({ input, output });
return;
} else if (typeof output !== 'string') {
}

if (typeof output !== 'string') {
error(
`File ${JSON.stringify(
file,
Expand Down Expand Up @@ -434,7 +436,7 @@ export async function install({
`Updated ${dependency.name} from ${oldVersion} to ${newVersion}`,
);
return newVersion;
} else {
success(`Installed ${dependency.name} ${newVersion}`);
}

success(`Installed ${dependency.name} ${newVersion}`);
}
10 changes: 5 additions & 5 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert } from './utils.js';

import toml, { Section } from '@ltd/j-toml';
import yaml from 'yaml';
import detectIndent from 'detect-indent';
import parseJson from 'parse-json';
import yaml from 'yaml';

import type {
ConfigFile,
Expand All @@ -13,9 +13,9 @@ import type {
VendorsOptions,
} from './types.js';

import { EOL } from 'os';
import { readFile, realpath, writeFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { readFile, realpath, writeFile } from 'node:fs/promises';
import { EOL } from 'node:os';
import path from 'node:path';

const defaultConfig = {
Expand Down Expand Up @@ -146,13 +146,13 @@ export async function writeConfig({
const indent = configFileSettings.indent;
const stringify = {
toml: (configFile: ConfigFile) => {
Object.keys(configFile.vendorDependencies).forEach((key) => {
for (const key of Object.keys(configFile.vendorDependencies)) {
if (configFile.vendorDependencies[key]) {
configFile.vendorDependencies[key] = Section(
configFile.vendorDependencies[key],
);
}
});
}
// @ts-expect-error toml doesn't understand that the ConfigFile type is just an object
return toml.stringify(configFile, {
newline: EOL,
Expand Down
8 changes: 4 additions & 4 deletions lib/github.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Repository } from './types.js';

import { assert, warning, success, error } from './utils.js';
import { assert, error, success, warning } from './utils.js';

import { Octokit } from '@octokit/rest';
import { createOAuthDeviceAuth } from '@octokit/auth-oauth-device';
import { g, s } from './auth.js';
import open from 'open';
import { Octokit } from '@octokit/rest';
import * as dotenv from 'dotenv';
import getEnvPaths from 'env-paths';
import _fetch from 'make-fetch-happen';
import open from 'open';
import { g, s } from './auth.js';

const envPaths = getEnvPaths('vendorfiles');
// @ts-expect-error - make-fetch-happen types are either wrong or bugged on my end
Expand Down
28 changes: 13 additions & 15 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { PackageJson } from 'type-fest';
import type {
FilesArray,
Lockfile,
Expand All @@ -7,19 +8,18 @@ import type {
VendorLock,
VendorLockFiles,
} from './types.js';
import type { PackageJson } from 'type-fest';

import { deepStrictEqual } from 'node:assert';
import { createWriteStream, existsSync } from 'node:fs';
import {
mkdir,
readFile,
writeFile,
readdir,
realpath,
rm,
readdir,
mkdir,
writeFile,
} from 'node:fs/promises';
import { createWriteStream, existsSync } from 'node:fs';
import path from 'node:path';
import { deepStrictEqual } from 'node:assert';
import { finished } from 'node:stream/promises';

import parseJson from 'parse-json';
Expand Down Expand Up @@ -214,8 +214,7 @@ export async function getAllFilesFromConfig() {
dependency.version || '',
),
);

filesFromConfig.forEach((file) => {
for (const file of filesFromConfig) {
files[
path.join(
getDependencyFolder({
Expand All @@ -227,7 +226,7 @@ export async function getAllFilesFromConfig() {
file,
)
] = name;
});
}
}

return files;
Expand Down Expand Up @@ -305,15 +304,15 @@ export async function getPackageJson(): Promise<PackageJson> {
return pkg;
}

// rome-ignore lint/suspicious/noExplicitAny: circular types are hard
// biome-ignore lint/suspicious/noExplicitAny: circular types are hard
export function replaceVersionInObject(obj: any, version: string) {
if (typeof obj === 'string') {
return replaceVersion(obj, version);
}
if (typeof obj === 'object') {
Object.keys(obj).forEach((key) => {
for (const key of Object.keys(obj)) {
obj[key] = replaceVersionInObject(obj[key], version);
});
}
}
return obj;
}
Expand All @@ -323,7 +322,7 @@ export function configFilesToVendorlockFiles(
version: string,
): VendorLockFiles {
const obj = {};
arr.forEach((item) => {
for (const item of arr) {
if (typeof item !== 'string') {
Object.assign(
obj,
Expand All @@ -334,8 +333,7 @@ export function configFilesToVendorlockFiles(
[item]: replaceVersion(path.basename(item), version),
});
}
return true;
});
}

return obj;
}
Expand Down
Loading
Loading