Skip to content

Commit

Permalink
Merge pull request #100 from nestdotland/dev
Browse files Browse the repository at this point in the history
0.3.1
  • Loading branch information
SteelAlloy authored Oct 25, 2020
2 parents f5ff3cc + 9417864 commit 7d55765
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
24 changes: 17 additions & 7 deletions src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import {
dim,
dirname,
existsSync,
globToRegExp,
gray,
green,
italic,
join,
log,
relative,
semver,
stringType,
yellow,
Expand Down Expand Up @@ -67,7 +69,7 @@ function ensureCompleteConfig(
isConfigComplete = false;
}

config.entry ||= "/mod.ts";
config.entry ||= "./mod.ts";
config.description ||= "";
config.homepage ||= "";
config.ignore ||= [];
Expand All @@ -82,11 +84,10 @@ function ensureFiles(config: Config, matched: MatchedFile[]): boolean {
log.warning("No README found at project root, continuing without one...");
}

config.entry = config.entry
?.replace(/^[.]/, "")
.replace(/^[^/]/, (s: string) => `/${s}`);
config.entry = "./" + relative(Deno.cwd(), config.entry).replace(/\\/g, "/");
const entryRegExp = globToRegExp(config.entry);

if (!matched.find((e) => e.path === config.entry)) {
if (!matched.find((e) => entryRegExp.test(e.path))) {
log.error(`${config.entry} was not found. This file is required.`);
return false;
}
Expand Down Expand Up @@ -322,7 +323,9 @@ export async function publish(options: Options, name?: string) {
stable: !(egg.unstable ?? isVersionUnstable(egg.version)),
upload: true,
latest: semver.compare(egg.version, latest) === 1,
entry: egg.entry,
entry: egg.entry.substr(1),
// TODO(@oganexon): make this format consistent between eggs & website
// (here we need to have "/" at the start of the string, where in the website "/" is removed)
};

log.info(
Expand Down Expand Up @@ -365,7 +368,14 @@ export async function publish(options: Options, name?: string) {
throw new Error("Something broke when publishing... ");
}

const pieceResponse = await postPieces(uploadResponse.token, matchedContent);
const pieceResponse = await postPieces(
uploadResponse.token,
Object.entries(matchedContent).reduce((prev, [key, value]) => {
prev[key.substr(1)] = value;
return prev;
}, {} as Record<string, string>),
);
// TODO(@oganexon): same, needs consistency

if (!pieceResponse) {
// TODO(@qu4k): provide better error reporting
Expand Down
13 changes: 9 additions & 4 deletions src/context/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function matchFiles(
]
.map((file) => ({
fullPath: file.path.replace(/\\/g, "/"),
path: "/" + relative(Deno.cwd(), file.path).replace(/\\/g, "/"),
path: "./" + relative(Deno.cwd(), file.path).replace(/\\/g, "/"),
lstat: Deno.lstatSync(file.path),
}));
if (matches.length === 0) {
Expand All @@ -49,7 +49,7 @@ export function matchFiles(
} else {
(ignore as Ignore).accepts.push(globToRegExp(config.entry));
for (const entry of walkSync(".")) {
const path = "/" + entry.path.replace(/\\/g, "/");
const path = "./" + entry.path.replace(/\\/g, "/");
const fullPath = resolve(entry.path);
const lstat = Deno.lstatSync(entry.path);
const file: MatchedFile = {
Expand All @@ -62,8 +62,13 @@ export function matchFiles(
}

matched = matched.filter((file) => file.lstat.isFile).filter((file) => {
if (ignore?.denies.some((rgx) => rgx.test(file.path.substr(1)))) {
return ignore.accepts.some((rgx) => rgx.test(file.path.substr(1)));
if (
ignore?.denies.some((rgx) =>
// check for "./" and ""
rgx.test(file.path) || rgx.test(file.path.substr(2))
)
) {
return ignore.accepts.some((rgx) => rgx.test(file.path));
}
return true;
});
Expand Down
3 changes: 3 additions & 0 deletions src/context/ignore_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ foo
foo
f o o
f\\ o\\ o
./foo
foo/
foo/bar
!test/should_keep_this.ts
Expand All @@ -30,6 +31,7 @@ foo/bar
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)*$/,
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)*$/,
/^(?:[^\\/]*(?:\\|\/|$)+)*f o o(?:\\|\/)*$/,
/^\.(?:\\|\/)+foo(?:\\|\/)*$/,
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)+(?:[^\\/]*(?:\\|\/|$)+)*$/,
/^foo(?:\\|\/)+bar(?:\\|\/)*$/,
/^\!test(?:\\|\/)+should_ignore_this\.ts(?:\\|\/)*$/,
Expand All @@ -49,6 +51,7 @@ foo/bar
/^(?:[^/]*(?:\/|$)+)*foo\/*$/,
/^(?:[^/]*(?:\/|$)+)*foo\/*$/,
/^(?:[^/]*(?:\/|$)+)*f o o\/*$/,
/^\.\/+foo\/*$/,
/^(?:[^/]*(?:\/|$)+)*foo\/+(?:[^/]*(?:\/|$)+)*$/,
/^foo\/+bar\/*$/,
/^\!test\/+should_ignore_this\.ts\/*$/,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "0.3.0";
export const version = "0.3.1";

0 comments on commit 7d55765

Please sign in to comment.