Skip to content

Commit

Permalink
chore: temporarily removed lime.
Browse files Browse the repository at this point in the history
  • Loading branch information
eser committed Dec 12, 2023
1 parent d8cfaf7 commit 23bb9b2
Show file tree
Hide file tree
Showing 913 changed files with 3,860 additions and 27,110 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ _etc/
.gitignore
.pre-commit-config.yaml
.tool-versions
CNAME
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ jobs:
- name: Check formatting, linting, license headers, types and run tests
run: deno task ok

- name: Create lcov file
run: deno task test:generate-lcov
- name: Generate coverage report
run: deno task test:coverage-gen

- name: Upload coverage
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
name: ${{ matrix.os }}
files: _etc/cov_profile.lcov
files: ./_etc/coverage.lcov
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Thumbs.db

# coverage files
/_etc/coverage/*
/_etc/cov_profile.lcov
/_etc/coverage.lcov

# package managers
node_modules/*
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
args: ["--maxkb=1024"]
exclude: |
(?x)^(
lime/src/build/esbuild_v0.19.2.wasm
lime/build/esbuild_v0.19.2.wasm
)$
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand All @@ -22,8 +22,9 @@ repos:
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/crate-ci/typos
rev: v1.16.22
rev: v1.16.23
hooks:
- id: typos
verbose: true
Expand All @@ -46,7 +47,7 @@ repos:
name: kebab-case files only
entry: filenames must be kebab-case only
language: fail
files: '[^a-z0-9.\-\/\[\]\@]'
files: '(?!\.test\.[jt]sx?$)[^a-z0-9.\/\[\]@-]'
exclude: |
(?x)^(
_etc/.*|
Expand All @@ -66,7 +67,6 @@ repos:
lime/.*|
parsing/README.md|
standards/README.md|
CNAME|
CODE_OF_CONDUCT.md|
CONTRIBUTING.md|
Dockerfile|
Expand Down
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"recommendations": [
"denoland.vscode-deno",
"ryanluker.vscode-coverage-gutters",
"ronilaukkarinen.vscode-stylefmt"
"ryanluker.vscode-coverage-gutters"
]
}
49 changes: 27 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
{
"coverage-gutters.coverageBaseDir": "**/_etc/coverage",
"coverage-gutters.coverageFileNames": ["cov_profile.lcov"],
"coverage-gutters.coverageBaseDir": "./_etc",
"coverage-gutters.coverageFileNames": [
"coverage.lcov"
],
"coverage-gutters.showGutterCoverage": true,
"coverage-gutters.showLineCoverage": true,
"coverage-gutters.showRulerCoverage": true,
"deno.cacheOnSave": true,
"deno.codeLens.implementations": true,
"deno.codeLens.references": true,
"deno.codeLens.referencesAllFunctions": true,
"deno.codeLens.test": true,
"deno.enable": true,
"deno.lint": true,
"deno.suggest.autoImports": true,
"deno.suggest.completeFunctionCalls": true,
"deno.suggest.imports.autoDiscover": true,
"deno.suggest.names": true,
"deno.suggest.paths": true,
"deno.unstable": true,
"javascript.suggest.autoImports": true,
"javascript.suggest.completeFunctionCalls": true,
"javascript.suggest.completeJSDocs": true,
"javascript.suggest.enabled": true,
"javascript.suggest.includeAutomaticOptionalChainCompletions": true,
"javascript.suggest.includeCompletionsForImportStatements": true,
"javascript.suggest.jsdoc.generateReturns": true,
"javascript.suggest.names": true,
"javascript.suggest.paths": true,
"typescript.suggest.autoImports": true,
"typescript.suggest.completeFunctionCalls": true,
"typescript.suggest.completeJSDocs": true,
"typescript.suggest.enabled": true,
"typescript.suggest.includeAutomaticOptionalChainCompletions": true,
"typescript.suggest.includeCompletionsForImportStatements": true,
"typescript.suggest.jsdoc.generateReturns": true,
"typescript.suggest.paths": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "./.github/workflows/*.yml"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[postcss]": {
"editor.defaultFormatter": "ronilaukkarinen.vscode-stylefmt"
},
"[javascriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[markdown]": {
"[typescript][typescriptreact][javascript][javascriptreact][markdown]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM denoland/deno:debian-1.36.4
FROM denoland/deno:distroless-1.38.5

EXPOSE 8080

Expand All @@ -8,5 +8,4 @@ USER deno

COPY ./ ./

ENTRYPOINT []
CMD ["deno", "task", "repl"]
ENTRYPOINT ["deno", "task", "repl"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 the cool authors.
Copyright 2023-present the cool authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
27 changes: 14 additions & 13 deletions _etc/tasks/check-license.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
// Copyright 2023 the cool authors. All rights reserved. Apache-2.0 license.
// Copyright 2023-present the cool authors. All rights reserved. Apache-2.0 license.
// Copied from $std/_tools/check_license.ts

import * as runtime from "../../standards/runtime.ts";
import { walk } from "$std/fs/walk.ts";

const EXTENSIONS = ["*.js", ".ts", "*.jsx", ".tsx"];

const ROOT = new URL("../../", import.meta.url);
const CHECK = Deno.args.includes("--check");
const CHECK = runtime.args.includes("--check");
const CURRENT_YEAR = new Date().getFullYear();
const RX_COPYRIGHT = new RegExp(
`// Copyright ([0-9]{4}) the cool authors\\. All rights reserved\\. ([0-9A-Za-z\-\.]+) license\\.\n`,
`// Copyright ([0-9]{4})-present the cool authors\\. All rights reserved\\. ([0-9A-Za-z\-\.]+) license\\.\n`,
);
const COPYRIGHT =
`// Copyright ${CURRENT_YEAR} the cool authors. All rights reserved. Apache-2.0 license.`;
`// Copyright ${CURRENT_YEAR}-present the cool authors. All rights reserved. Apache-2.0 license.`;

let failed = false;

for await (
const { path } of walk(ROOT, {
const entry of walk(ROOT, {
exts: EXTENSIONS,
skip: [
/_etc\/coverage\/*$/,
Expand All @@ -28,34 +29,34 @@ for await (
includeDirs: false,
})
) {
const content = await Deno.readTextFile(path);
const content = await runtime.readTextFile(entry.path);
const match = content.match(RX_COPYRIGHT);

if (!match) {
if (CHECK) {
console.error(`Missing copyright header: ${path}`);
console.error(`Missing copyright header: ${entry.path}`);
failed = true;
} else {
const contentWithCopyright = COPYRIGHT + "\n" + content;
await Deno.writeTextFile(path, contentWithCopyright);
console.log("Copyright header automatically added to " + path);
await runtime.writeTextFile(entry.path, contentWithCopyright);
console.log("Copyright header automatically added to " + entry.path);
}
} else if (parseInt(match[1]) !== CURRENT_YEAR) {
if (CHECK) {
console.error(`Incorrect copyright year: ${path}`);
console.error(`Incorrect copyright year: ${entry.path}`);
failed = true;
} else {
const index = match.index ?? 0;
const contentWithoutCopyright = content.replace(match[0], "");
const contentWithCopyright = contentWithoutCopyright.substring(0, index) +
COPYRIGHT + "\n" + contentWithoutCopyright.substring(index);
await Deno.writeTextFile(path, contentWithCopyright);
console.log("Copyright header automatically updated in " + path);
await runtime.writeTextFile(entry.path, contentWithCopyright);
console.log("Copyright header automatically updated in " + entry.path);
}
}
}

if (failed) {
console.info(`Copyright header should be "${COPYRIGHT}"`);
Deno.exit(1);
runtime.exit(1);
}
2 changes: 1 addition & 1 deletion appserver/appserver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 the cool authors. All rights reserved. Apache-2.0 license.
// Copyright 2023-present the cool authors. All rights reserved. Apache-2.0 license.

import { events } from "../events/events.ts";
import { di } from "../di/services.ts";
Expand Down
2 changes: 1 addition & 1 deletion appserver/channel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 the cool authors. All rights reserved. Apache-2.0 license.
// Copyright 2023-present the cool authors. All rights reserved. Apache-2.0 license.

export interface Channel {
name?: string;
Expand Down
2 changes: 1 addition & 1 deletion appserver/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 the cool authors. All rights reserved. Apache-2.0 license.
// Copyright 2023-present the cool authors. All rights reserved. Apache-2.0 license.

export * from "./module.ts";
export * from "./appserver.ts";
2 changes: 1 addition & 1 deletion appserver/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 the cool authors. All rights reserved. Apache-2.0 license.
// Copyright 2023-present the cool authors. All rights reserved. Apache-2.0 license.

export interface Module {
name?: string;
Expand Down
29 changes: 29 additions & 0 deletions appserver/version-checker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023-present the cool authors. All rights reserved. MIT license.

import * as semver from "$std/semver/mod.ts";
import * as runtime from "../standards/runtime.ts";

export function compareSemanticVersions(
currentVersion: semver.SemVer,
targetVersion: semver.SemVerRange | semver.SemVer,
) {
if (semver.isSemVerRange(targetVersion)) {
return semver.testRange(currentVersion, targetVersion);
}

return !semver.gte(currentVersion, targetVersion);
}

export function compareTextVersions(
currentVersion: string,
targetVersion: string,
) {
const currentSemanticVersion = semver.parse(currentVersion);
const targetSemanticVersion = semver.parseRange(targetVersion);

return compareSemanticVersions(currentSemanticVersion, targetSemanticVersion);
}

export function checkMinDenoVersion(minimumVersion: string) {
return compareTextVersions(runtime.version.runtime, minimumVersion);
}
74 changes: 74 additions & 0 deletions collector/collector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2023-present the cool authors. All rights reserved. MIT license.

import * as path from "$std/path/mod.ts";
import * as walk from "$std/fs/walk.ts";
import * as patterns from "../standards/patterns.ts";

export async function* walkFiles(
baseDir: string,
globFilter: string | undefined,
ignoreFilePattern: RegExp,
) {
const routesFolder = walk.walk(baseDir, {
includeDirs: false,
includeFiles: true,
exts: patterns.JS_FILE_EXTENSIONS,
skip: [ignoreFilePattern],
});

for await (const entry of routesFolder) {
const rel = path.relative(baseDir, entry.path);

if (globFilter !== undefined && !path.globToRegExp(globFilter).test(rel)) {
continue;
}

yield rel;
}
}

export interface CollectExportsOptions {
baseDir: string;
globFilter?: string;
exportFilter?: (entries: [string, unknown][]) => [string, unknown][];
ignoreFilePattern?: RegExp;
}

export async function collectExports(options: CollectExportsOptions) {
const ignoreFilePattern = options.ignoreFilePattern ??
patterns.JS_TEST_FILE_PATTERN;

const exports: Array<[string, Array<[string, unknown]>]> = [];

for await (
const entry of walkFiles(
options.baseDir,
options.globFilter,
ignoreFilePattern,
)
) {
const entryUri = `${options.baseDir}/${entry}`;

try {
const entryModule = await import(entryUri);
const moduleExports = Object.entries(entryModule);

if (options.exportFilter === undefined) {
exports.push([entry, moduleExports]);
continue;
}

const selectedExports = options.exportFilter(moduleExports);

if (selectedExports.length === 0) {
continue;
}

exports.push([entry, selectedExports]);
} catch (err) {
console.error(err);
}
}

return exports;
}
25 changes: 25 additions & 0 deletions collector/formatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023-present the cool authors. All rights reserved. MIT license.

import * as runtime from "../standards/runtime.ts";

export const format = async (input: string) => {
const proc = new runtime.Command(runtime.execPath(), {
args: ["fmt", "-"],
stdin: "piped",
stdout: "piped",
stderr: "null",
}).spawn();

const raw = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode(input));
controller.close();
},
});
await raw.pipeTo(proc.stdin);
const { stdout } = await proc.output();

const result = new TextDecoder().decode(stdout);

return result;
};
Loading

0 comments on commit 23bb9b2

Please sign in to comment.