Skip to content

Commit 7d55765

Browse files
authored
Merge pull request #100 from nestdotland/dev
0.3.1
2 parents f5ff3cc + 9417864 commit 7d55765

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

src/commands/publish.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import {
77
dim,
88
dirname,
99
existsSync,
10+
globToRegExp,
1011
gray,
1112
green,
1213
italic,
1314
join,
1415
log,
16+
relative,
1517
semver,
1618
stringType,
1719
yellow,
@@ -67,7 +69,7 @@ function ensureCompleteConfig(
6769
isConfigComplete = false;
6870
}
6971

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

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

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

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

368-
const pieceResponse = await postPieces(uploadResponse.token, matchedContent);
371+
const pieceResponse = await postPieces(
372+
uploadResponse.token,
373+
Object.entries(matchedContent).reduce((prev, [key, value]) => {
374+
prev[key.substr(1)] = value;
375+
return prev;
376+
}, {} as Record<string, string>),
377+
);
378+
// TODO(@oganexon): same, needs consistency
369379

370380
if (!pieceResponse) {
371381
// TODO(@qu4k): provide better error reporting

src/context/files.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function matchFiles(
3333
]
3434
.map((file) => ({
3535
fullPath: file.path.replace(/\\/g, "/"),
36-
path: "/" + relative(Deno.cwd(), file.path).replace(/\\/g, "/"),
36+
path: "./" + relative(Deno.cwd(), file.path).replace(/\\/g, "/"),
3737
lstat: Deno.lstatSync(file.path),
3838
}));
3939
if (matches.length === 0) {
@@ -49,7 +49,7 @@ export function matchFiles(
4949
} else {
5050
(ignore as Ignore).accepts.push(globToRegExp(config.entry));
5151
for (const entry of walkSync(".")) {
52-
const path = "/" + entry.path.replace(/\\/g, "/");
52+
const path = "./" + entry.path.replace(/\\/g, "/");
5353
const fullPath = resolve(entry.path);
5454
const lstat = Deno.lstatSync(entry.path);
5555
const file: MatchedFile = {
@@ -62,8 +62,13 @@ export function matchFiles(
6262
}
6363

6464
matched = matched.filter((file) => file.lstat.isFile).filter((file) => {
65-
if (ignore?.denies.some((rgx) => rgx.test(file.path.substr(1)))) {
66-
return ignore.accepts.some((rgx) => rgx.test(file.path.substr(1)));
65+
if (
66+
ignore?.denies.some((rgx) =>
67+
// check for "./" and ""
68+
rgx.test(file.path) || rgx.test(file.path.substr(2))
69+
)
70+
) {
71+
return ignore.accepts.some((rgx) => rgx.test(file.path));
6772
}
6873
return true;
6974
});

src/context/ignore_test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ foo
1313
foo
1414
f o o
1515
f\\ o\\ o
16+
./foo
1617
foo/
1718
foo/bar
1819
!test/should_keep_this.ts
@@ -30,6 +31,7 @@ foo/bar
3031
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)*$/,
3132
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)*$/,
3233
/^(?:[^\\/]*(?:\\|\/|$)+)*f o o(?:\\|\/)*$/,
34+
/^\.(?:\\|\/)+foo(?:\\|\/)*$/,
3335
/^(?:[^\\/]*(?:\\|\/|$)+)*foo(?:\\|\/)+(?:[^\\/]*(?:\\|\/|$)+)*$/,
3436
/^foo(?:\\|\/)+bar(?:\\|\/)*$/,
3537
/^\!test(?:\\|\/)+should_ignore_this\.ts(?:\\|\/)*$/,
@@ -49,6 +51,7 @@ foo/bar
4951
/^(?:[^/]*(?:\/|$)+)*foo\/*$/,
5052
/^(?:[^/]*(?:\/|$)+)*foo\/*$/,
5153
/^(?:[^/]*(?:\/|$)+)*f o o\/*$/,
54+
/^\.\/+foo\/*$/,
5255
/^(?:[^/]*(?:\/|$)+)*foo\/+(?:[^/]*(?:\/|$)+)*$/,
5356
/^foo\/+bar\/*$/,
5457
/^\!test\/+should_ignore_this\.ts\/*$/,

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = "0.3.0";
1+
export const version = "0.3.1";

0 commit comments

Comments
 (0)