@adonisjs/assembler 6.1.3-12 → 6.1.3-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,12 +7,11 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import slash from 'slash';
10
- import copyfiles from 'cpy';
11
10
  import fs from 'node:fs/promises';
12
11
  import { fileURLToPath } from 'node:url';
13
12
  import { join, relative } from 'node:path';
14
13
  import { cliui } from '@poppinss/cliui';
15
- import { run, parseConfig } from './helpers.js';
14
+ import { run, parseConfig, copyFiles } from './helpers.js';
16
15
  /**
17
16
  * Instance of CLIUI
18
17
  */
@@ -89,7 +88,7 @@ export class Bundler {
89
88
  */
90
89
  async #copyFiles(files, outDir) {
91
90
  try {
92
- await copyfiles(files, outDir, { parents: true, cwd: this.#cwdPath });
91
+ await copyFiles(files, this.#cwdPath, outDir);
93
92
  }
94
93
  catch (error) {
95
94
  if (!error.message.includes("the file doesn't exist")) {
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ declare const _default: import("util").DebugLogger;
3
+ export default _default;
@@ -0,0 +1,10 @@
1
+ /*
2
+ * @adonisjs/assembler
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { debuglog } from 'node:util';
10
+ export default debuglog('adonisjs:assembler');
@@ -43,3 +43,8 @@ export declare function isRcFile(filePath: string): boolean;
43
43
  * stops after first find.
44
44
  */
45
45
  export declare function getPort(cwd: URL): Promise<number>;
46
+ /**
47
+ * Helper function to copy files from relative paths or glob
48
+ * patterns
49
+ */
50
+ export declare function copyFiles(files: string[], cwd: string, outDir: string): Promise<string[]>;
@@ -6,11 +6,16 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ import cpy from 'cpy';
10
+ import { isNotJunk } from 'junk';
11
+ import fastGlob from 'fast-glob';
9
12
  import getRandomPort from 'get-port';
10
13
  import { fileURLToPath } from 'node:url';
11
14
  import { execaNode, execa } from 'execa';
15
+ import { isAbsolute, relative } from 'node:path';
12
16
  import { EnvLoader, EnvParser } from '@adonisjs/env';
13
17
  import { ConfigParser, Watcher } from '@poppinss/chokidar-ts';
18
+ import debug from './debug.js';
14
19
  /**
15
20
  * Default set of args to pass in order to run TypeScript
16
21
  * source. Used by "run" and "runNode" scripts
@@ -140,3 +145,37 @@ export async function getPort(cwd) {
140
145
  */
141
146
  return getRandomPort({ port: 3333 });
142
147
  }
148
+ /**
149
+ * Helper function to copy files from relative paths or glob
150
+ * patterns
151
+ */
152
+ export async function copyFiles(files, cwd, outDir) {
153
+ /**
154
+ * Looping over files and create a new collection with paths
155
+ * and glob patterns
156
+ */
157
+ const { paths, patterns } = files.reduce((result, file) => {
158
+ if (fastGlob.isDynamicPattern(file)) {
159
+ result.patterns.push(file);
160
+ }
161
+ else {
162
+ result.paths.push(file);
163
+ }
164
+ return result;
165
+ }, { patterns: [], paths: [] });
166
+ debug('copyFiles inputs: %O, paths: %O, patterns: %O', files, paths, patterns);
167
+ /**
168
+ * Getting list of relative paths from glob patterns
169
+ */
170
+ const filePaths = paths.concat(await fastGlob(patterns, { cwd }));
171
+ /**
172
+ * Computing relative destination. This is because, cpy is buggy when
173
+ * outDir is an absolute path.
174
+ */
175
+ const destination = isAbsolute(outDir) ? relative(cwd, outDir) : outDir;
176
+ debug('copying files %O to destination "%s"', filePaths, destination);
177
+ return cpy(filePaths.filter(isNotJunk), destination, {
178
+ cwd: cwd,
179
+ flat: false,
180
+ });
181
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/assembler",
3
- "version": "6.1.3-12",
3
+ "version": "6.1.3-13",
4
4
  "description": "Provides utilities to run AdonisJS development server and build project for production",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -66,9 +66,11 @@
66
66
  "@adonisjs/env": "^4.2.0-3",
67
67
  "@poppinss/chokidar-ts": "^4.1.0-4",
68
68
  "@poppinss/cliui": "^6.1.1-3",
69
- "cpy": "^8.1.2",
69
+ "cpy": "^10.1.0",
70
70
  "execa": "^7.0.0",
71
+ "fast-glob": "^3.3.0",
71
72
  "get-port": "^7.0.0",
73
+ "junk": "^4.0.1",
72
74
  "picomatch": "^2.3.1",
73
75
  "slash": "^5.1.0"
74
76
  },