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

chore: update utils #30

Merged
merged 3 commits into from
May 15, 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
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
2 changes: 1 addition & 1 deletion test/cache-buster/cacheBuster.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { existsSync } from 'node:fs';
import { join } from 'upath';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { cacheBuster } from '../../src/cache-buster/index.js';
import { Asset, AssetPack, path } from '../../src/core/index.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'cache-buster';

Expand Down
2 changes: 1 addition & 1 deletion test/core/AssetWatcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getInputDir } from '../../shared/test/index.js';
import { Asset } from '../../src/core/Asset.js';
import { AssetCache } from '../../src/core/AssetCache.js';
import { AssetWatcher } from '../../src/core/AssetWatcher.js';
import { logAssetGraph } from '../../src/core/utils/logAssetGraph.js';
import { assetPath, createFolder, getInputDir } from '../utils/index.js';

const pkg = 'core';

Expand Down
8 changes: 4 additions & 4 deletions test/core/Assetpack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import fs from 'fs-extra';
import { existsSync } from 'node:fs';
import { join } from 'path';
import { describe, expect, it } from 'vitest';
import { AssetPack } from '../../src/core/AssetPack.js';
import { logAssetGraph } from '../../src/core/utils/logAssetGraph.js';
import {
assetPath,
createAssetPipe,
createFolder,
getCacheDir,
getInputDir,
getOutputDir
} from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/AssetPack.js';
import { logAssetGraph } from '../../src/core/utils/logAssetGraph.js';
} from '../utils/index.js';

import type { MockAssetPipe } from '../../shared/test/index.js';
import type { AssetPipe } from '../../src/core/pipes/AssetPipe.js';
import type { MockAssetPipe } from '../utils/index.js';

const pkg = 'core';

Expand Down
2 changes: 1 addition & 1 deletion test/core/Utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from 'vitest';
import { createAssetPipe, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/AssetPack.js';
import { extractTagsFromFileName } from '../../src/core/utils/extractTagsFromFileName.js';
import { generateCacheName } from '../../src/core/utils/generateCacheName.js';
import { createAssetPipe, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

import type { Asset } from '../../src/core/Asset.js';
import type { AssetPipe } from '../../src/core/index.js';
Expand Down
2 changes: 1 addition & 1 deletion test/core/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { createAssetPipe } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { createAssetPipe } from '../utils/index.js';

import type { AssetPackConfig } from '../../src/core/config.js';

Expand Down
2 changes: 1 addition & 1 deletion test/ffmpeg/Audio.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync } from 'node:fs';
import { describe, expect, it, vi } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { audio } from '../../src/ffmpeg/index.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'ffmpeg';

Expand Down
2 changes: 1 addition & 1 deletion test/image/Compress.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { compress } from '../../src/image/compress.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'image';

Expand Down
2 changes: 1 addition & 1 deletion test/image/Mipmap.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { mipmap } from '../../src/image/mipmap.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'image';

Expand Down
2 changes: 1 addition & 1 deletion test/json/Json.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { existsSync, readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { json } from '../../src/json/index.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'json';

Expand Down
16 changes: 8 additions & 8 deletions test/manifest/Manifest.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import fs from 'fs-extra';
import { existsSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import {
assetPath,
createFolder,
getCacheDir,
getInputDir,
getOutputDir
} from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { audio } from '../../src/ffmpeg/index.js';
import { compress, mipmap } from '../../src/image/index.js';
import { pixiManifest } from '../../src/manifest/index.js';
import { spineAtlasManifestMod, spineAtlasMipmap } from '../../src/spine/index.js';
import { texturePacker, texturePackerManifestMod } from '../../src/texture-packer/index.js';
import {
assetPath,
createFolder,
getCacheDir,
getInputDir,
getOutputDir
} from '../utils/index.js';

import type { File } from '../../shared/test/index.js';
import type { File } from '../utils/index.js';

const pkg = 'manifest';

Expand Down
2 changes: 1 addition & 1 deletion test/spine/spineAtlasAll.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { glob } from 'glob';
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { cacheBuster } from '../../src/cache-buster/index.js';
import { AssetPack } from '../../src/core/index.js';
import { compress, mipmap } from '../../src/image/index.js';
import { spineAtlasCacheBuster } from '../../src/spine/spineAtlasCacheBuster.js';
import { spineAtlasCompress } from '../../src/spine/spineAtlasCompress.js';
import { spineAtlasMipmap } from '../../src/spine/spineAtlasMipmap.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'spine';

Expand Down
2 changes: 1 addition & 1 deletion test/spine/spineAtlasCacheBuster.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { glob } from 'glob';
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { cacheBuster } from '../../src/cache-buster/index.js';
import { AssetPack } from '../../src/core/index.js';
import { spineAtlasCacheBuster } from '../../src/spine/spineAtlasCacheBuster.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'spine';

Expand Down
2 changes: 1 addition & 1 deletion test/spine/spineAtlasCompress.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { compress } from '../../src/image/index.js';
import { spineAtlasCompress } from '../../src/spine/spineAtlasCompress.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'spine';

Expand Down
2 changes: 1 addition & 1 deletion test/spine/spineAtlasManifest.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { pixiManifest } from '../../src/manifest/index.js';
import { spineAtlasManifestMod } from '../../src/spine/spineAtlasManifestMod.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'spine';

Expand Down
2 changes: 1 addition & 1 deletion test/spine/spineAtlasMipmap.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { existsSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack } from '../../src/core/index.js';
import { mipmap } from '../../src/image/index.js';
import { spineAtlasMipmap } from '../../src/spine/spineAtlasMipmap.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'spine';

Expand Down
41 changes: 8 additions & 33 deletions test/texture-packer/texturePacker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,15 @@ import fs from 'fs-extra';
import { existsSync } from 'node:fs';
import sharp from 'sharp';
import { describe, expect, it, vi } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { AssetPack, Logger } from '../../src/core/index.js';
import { texturePacker } from '../../src/texture-packer/texturePacker.js';
import { createTPSFolder } from '../utils/createTPSFolder.js';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

import type { File } from '../../shared/test/index.js';
import type { File } from '../utils/index.js';

const pkg = 'texture-packer';

function genFolder(testName: string)
{
const sprites: File[] = [];

for (let i = 0; i < 10; i++)
{
sprites.push({
name: `sprite${i}.png`,
content: assetPath(`image/sp-${i + 1}.png`),
});
}
createFolder(
pkg,
{
name: testName,
files: [],
folders: [
{
name: 'sprites{tps}',
files: sprites,
folders: [],
},
],
});
}

describe('Texture Packer', () =>
{
it('should create a sprite sheet', async () =>
Expand All @@ -44,7 +19,7 @@ describe('Texture Packer', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down Expand Up @@ -83,7 +58,7 @@ describe('Texture Packer', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const size = 512;

Expand Down Expand Up @@ -119,7 +94,7 @@ describe('Texture Packer', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down Expand Up @@ -152,7 +127,7 @@ describe('Texture Packer', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down Expand Up @@ -276,7 +251,7 @@ describe('Texture Packer', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down
33 changes: 3 additions & 30 deletions test/texture-packer/texturePackerAll.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,17 @@
import fs from 'fs-extra';
import { glob } from 'glob';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { cacheBuster } from '../../src/cache-buster/index.js';
import { AssetPack } from '../../src/core/index.js';
import { compress, mipmap } from '../../src/image/index.js';
import { texturePacker } from '../../src/texture-packer/texturePacker.js';
import { texturePackerCacheBuster } from '../../src/texture-packer/texturePackerCacheBuster.js';
import { texturePackerCompress } from '../../src/texture-packer/texturePackerCompress.js';

import type { File } from '../../shared/test/index.js';
import { createTPSFolder } from '../utils/createTPSFolder.js';
import { getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'texture-packer';

function genFolder(testName: string)
{
const sprites: File[] = [];

for (let i = 0; i < 10; i++)
{
sprites.push({
name: `sprite${i}.png`,
content: assetPath(`image/sp-${i + 1}.png`),
});
}
createFolder(
pkg,
{
name: testName,
files: [],
folders: [
{
name: 'sprites{tps}',
files: sprites,
folders: [],
},
],
});
}

describe('Texture Packer All', () =>
{
it('should create a sprite sheet mip, compress and cache bust', async () =>
Expand All @@ -47,7 +20,7 @@ describe('Texture Packer All', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down
33 changes: 3 additions & 30 deletions test/texture-packer/texturePackerCacheBuster.test.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,15 @@
import fs from 'fs-extra';
import { glob } from 'glob';
import { describe, expect, it } from 'vitest';
import { assetPath, createFolder, getCacheDir, getInputDir, getOutputDir } from '../../shared/test/index.js';
import { cacheBuster } from '../../src/cache-buster/index.js';
import { AssetPack } from '../../src/core/index.js';
import { texturePacker } from '../../src/texture-packer/texturePacker.js';
import { texturePackerCacheBuster } from '../../src/texture-packer/texturePackerCacheBuster.js';

import type { File } from '../../shared/test/index.js';
import { createTPSFolder } from '../utils/createTPSFolder.js';
import { getCacheDir, getInputDir, getOutputDir } from '../utils/index.js';

const pkg = 'texture-packer';

function genFolder(testName: string)
{
const sprites: File[] = [];

for (let i = 0; i < 10; i++)
{
sprites.push({
name: `sprite${i}.png`,
content: assetPath(`image/sp-${i + 1}.png`),
});
}
createFolder(
pkg,
{
name: testName,
files: [],
folders: [
{
name: 'sprites{tps}',
files: sprites,
folders: [],
},
],
});
}

describe('Texture Packer Cache Buster', () =>
{
it('should create a sprite sheet and correctly update json', async () =>
Expand All @@ -45,7 +18,7 @@ describe('Texture Packer Cache Buster', () =>
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

genFolder(testName);
createTPSFolder(testName, pkg);

const assetpack = new AssetPack({
entry: inputDir, cacheLocation: getCacheDir(pkg, testName),
Expand Down
Loading
Loading