@@ -50,67 +50,6 @@ function collectUnusedDependencies(pathToProject = process.cwd()) {
50
50
} ) ;
51
51
}
52
52
53
- /**
54
- * `pathToZip` is a `path/to/your/app-name.zip`.
55
- * If the `pathToZip` archive does not have a root directory with name `app-name`, it creates one, and move the content from the
56
- * archive's root to the new root folder. If the archive already has the desired root folder, calling this function is a NOOP.
57
- * If `pathToZip` is not a ZIP, rejects. `targetFolderName` is the destination folder not the new archive location.
58
- */
59
- function adjustArchiveStructure ( pathToZip , targetFolderName , noCleanup ) {
60
- return new Promise ( async ( resolve , reject ) => {
61
- if ( ! ( await isZip ( pathToZip ) ) ) {
62
- reject ( new Error ( `Expected a ZIP file.` ) ) ;
63
- return ;
64
- }
65
- if ( ! fs . existsSync ( targetFolderName ) ) {
66
- reject ( new Error ( `${ targetFolderName } does not exist.` ) ) ;
67
- return ;
68
- }
69
- if ( ! fs . lstatSync ( targetFolderName ) . isDirectory ( ) ) {
70
- reject ( new Error ( `${ targetFolderName } is not a directory.` ) ) ;
71
- return ;
72
- }
73
- console . log ( `⏱️ >>> Adjusting ZIP structure ${ pathToZip } ...` ) ;
74
-
75
- const root = basename ( pathToZip ) ;
76
- const resources = await list ( pathToZip ) ;
77
- const hasBaseFolder = resources . find ( ( name ) => name === root ) ;
78
- if ( hasBaseFolder ) {
79
- if (
80
- resources . filter ( ( name ) => name . indexOf ( path . sep ) === - 1 ) . length > 1
81
- ) {
82
- console . warn (
83
- `${ pathToZip } ZIP has the desired root folder ${ root } , however the ZIP contains other entries too: ${ JSON . stringify (
84
- resources
85
- ) } `
86
- ) ;
87
- }
88
- console . log ( `👌 <<< The ZIP already has the desired ${ root } folder.` ) ;
89
- resolve ( pathToZip ) ;
90
- return ;
91
- }
92
-
93
- const track = temp . track ( ) ;
94
- try {
95
- const unzipOut = path . join ( track . mkdirSync ( ) , root ) ;
96
- fs . mkdirSync ( unzipOut ) ;
97
- await unpack ( pathToZip , unzipOut ) ;
98
- const adjustedZip = path . join ( targetFolderName , path . basename ( pathToZip ) ) ;
99
- await pack ( unzipOut , adjustedZip ) ;
100
- console . log (
101
- `👌 <<< Adjusted the ZIP structure. Moved the modified ${ basename (
102
- pathToZip
103
- ) } to the ${ targetFolderName } folder.`
104
- ) ;
105
- resolve ( adjustedZip ) ;
106
- } finally {
107
- if ( ! noCleanup ) {
108
- track . cleanupSync ( ) ;
109
- }
110
- }
111
- } ) ;
112
- }
113
-
114
53
/**
115
54
* Returns the `basename` of `pathToFile` without the file extension.
116
55
*/
@@ -213,7 +152,6 @@ function getChannelFile(platform) {
213
152
214
153
module . exports = {
215
154
collectUnusedDependencies,
216
- adjustArchiveStructure,
217
155
isZip,
218
156
unpack,
219
157
isNightly,
0 commit comments