ZachHandley
ZachHandley
Explore posts from servers
CDCloudflare Developers
Created by ZachHandley on 7/25/2024 in #pages-help
string-width build error with Astro?
Hey, so I updated Astro, and now my builds are getting this error
21:54:35.444 Executing user command: bun run build
21:54:35.714 $ astro check && astro build
21:54:36.479 /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3
21:54:36.479 const stringWidth = require('string-width')
21:54:36.479 ^
21:54:36.480
21:54:36.480 Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/webserver/node_modules/string-width/index.js from /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js not supported.
21:54:36.480 Instead change the require of /opt/buildhome/repo/webserver/node_modules/string-width/index.js in /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js to a dynamic import() which is available in all CommonJS modules.
21:54:36.480 at Object.<anonymous> (/opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3:21) {
21:54:36.480 code: 'ERR_REQUIRE_ESM'
21:54:36.480 }
21:54:36.480
21:54:36.480 Node.js v18.17.1
21:54:36.491 error: script "build" exited with code 1 (SIGHUP)
21:54:36.493 Failed: Error while executing user command. Exited with error code: 1
21:54:36.502 Failed: build command exited with code: 1
21:54:37.494 Failed: error occurred while running build comman
21:54:35.444 Executing user command: bun run build
21:54:35.714 $ astro check && astro build
21:54:36.479 /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3
21:54:36.479 const stringWidth = require('string-width')
21:54:36.479 ^
21:54:36.480
21:54:36.480 Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/buildhome/repo/webserver/node_modules/string-width/index.js from /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js not supported.
21:54:36.480 Instead change the require of /opt/buildhome/repo/webserver/node_modules/string-width/index.js in /opt/buildhome/repo/webserver/node_modules/ansi-align/index.js to a dynamic import() which is available in all CommonJS modules.
21:54:36.480 at Object.<anonymous> (/opt/buildhome/repo/webserver/node_modules/ansi-align/index.js:3:21) {
21:54:36.480 code: 'ERR_REQUIRE_ESM'
21:54:36.480 }
21:54:36.480
21:54:36.480 Node.js v18.17.1
21:54:36.491 error: script "build" exited with code 1 (SIGHUP)
21:54:36.493 Failed: Error while executing user command. Exited with error code: 1
21:54:36.502 Failed: build command exited with code: 1
21:54:37.494 Failed: error occurred while running build comman
I can't figure out why, I ran npm list string-width and this is what I got
socialaize-webserver@0.1.0 /home/zach/GitHub/socialaize/webserver
├─┬ @astrojs/check@0.8.2
│ └─┬ yargs@17.7.2
│ ├─┬ cliui@8.0.1
│ │ ├── string-width@4.2.3
│ │ └─┬ wrap-ansi@7.0.0
│ │ └── string-width@4.2.3 deduped
│ └── string-width@4.2.3
├─┬ @playform/compress@0.0.4
│ └─┬ astro@4.8.1
│ └── string-width@7.1.0
├─┬ astro@4.12.2
│ ├─┬ boxen@7.1.1
│ │ ├─┬ ansi-align@3.0.1
│ │ │ └── string-width@4.2.3
│ │ ├── string-width@5.1.2
│ │ ├─┬ widest-line@4.0.1
│ │ │ └── string-width@5.1.2
│ │ └─┬ wrap-ansi@8.1.0
│ │ └── string-width@5.1.2
│ ├─┬ ora@8.0.1
│ │ └── string-width@7.1.0
│ └── string-width@7.2.0
└─┬ tailwindcss@3.4.6
└─┬ sucrase@3.35.0
└─┬ glob@10.4.1
└─┬ jackspeak@3.3.0
└─┬ @isaacs/cliui@8.0.2
├── string-width@5.1.2
└─┬ wrap-ansi-cjs@npm:wrap-ansi@7.0.0
└── string-width@4.2.3
socialaize-webserver@0.1.0 /home/zach/GitHub/socialaize/webserver
├─┬ @astrojs/check@0.8.2
│ └─┬ yargs@17.7.2
│ ├─┬ cliui@8.0.1
│ │ ├── string-width@4.2.3
│ │ └─┬ wrap-ansi@7.0.0
│ │ └── string-width@4.2.3 deduped
│ └── string-width@4.2.3
├─┬ @playform/compress@0.0.4
│ └─┬ astro@4.8.1
│ └── string-width@7.1.0
├─┬ astro@4.12.2
│ ├─┬ boxen@7.1.1
│ │ ├─┬ ansi-align@3.0.1
│ │ │ └── string-width@4.2.3
│ │ ├── string-width@5.1.2
│ │ ├─┬ widest-line@4.0.1
│ │ │ └── string-width@5.1.2
│ │ └─┬ wrap-ansi@8.1.0
│ │ └── string-width@5.1.2
│ ├─┬ ora@8.0.1
│ │ └── string-width@7.1.0
│ └── string-width@7.2.0
└─┬ tailwindcss@3.4.6
└─┬ sucrase@3.35.0
└─┬ glob@10.4.1
└─┬ jackspeak@3.3.0
└─┬ @isaacs/cliui@8.0.2
├── string-width@5.1.2
└─┬ wrap-ansi-cjs@npm:wrap-ansi@7.0.0
└── string-width@4.2.3
Any help is appreciated
2 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/19/2024 in #sapphire-support
Just curious, can I declare a map of string to Class on container as a type?
No description
6 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Decorators Message Context?
The decorators don't really say, can I use them on top of an interaction? If not, what's the recommended flow to use the decorators e.g. RequiresGuildContext() on things like a command rather than a subcommand?
89 replies
SIASapphire - Imagine a framework
Created by ZachHandley on 3/15/2024 in #sapphire-support
Scope of Command Classes?
Hi just curious, what's the scope of command classes? Is a class created each time you run the command, or
export class ConfigCommand extends Command {
supportChannel: Channel | null = null;
settingsEmbed: EmbedBuilder | null = null;
permittedRoles: string[] = [];
export class ConfigCommand extends Command {
supportChannel: Channel | null = null;
settingsEmbed: EmbedBuilder | null = null;
permittedRoles: string[] = [];
when a guild user runs this command, is the support channel per-command instance or per bot?
78 replies
TSDThe Swift Den
Created by ZachHandley on 3/3/2023 in #swift-development
Alamofire 5.X "Type of expression is ambiguous without more context"
Title. I've been messing with this for almost a full hour and can't fix this stupid error message
let urlString = "\(baseURL)\(header)"
let jsonData : Data = try! JSONSerialization.data(withJSONObject: parameter, options: .prettyPrinted)

let jsonString = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue)! as String

print("JSON Params->\(jsonString)")

let headers: HTTPHeaders = [
"Authorization": "XXXXXX",
"Accept": "application/json",
"Content-Type": "application/json"
]


let uploadUrl = try! URLRequest(url: URL(string:urlString)!, method: .post, headers: headers)
AF.upload(
multipartFormData: { (multiPart) in
var keys = [String]()

for (key, img) in images {
if let imageData = img.jpegData(compressionQuality: compressRatio) {
multiPart.append(imageData, withName: key, fileName: key+".png", mimeType: "image/png")
keys.append(key)
}
}

let jsonName = try! JSONSerialization.data(withJSONObject: ["count": keys.count], options: .prettyPrinted)

multiPart.append(jsonName, withName: "names")
multiPart.append(jsonData, withName: "data")
}, with: uploadUrl, encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON{ response in
if hud{
Loader.init().hide(delegate: vc)
}

switch response.result {
case .success(_):
print("Response->\(response.value)")

if response.value != nil {
let JSON = response.value! as AnyObject
let response = JSON["response"] as! NSDictionary

let success = response.value(forKey: "status")
let success_message = response.value(forKey: "success_message")
let error_message = response.value(forKey: "error_message")

if success as! String {
completion(response.replaceNullsWithBlanks() as NSDictionary, success_message as NSString, true)
} else {
print("Upload failed")
completion([:], error_message as NSString, false)

if alertMsg {
self.presentAlertWithTitle(title: "Alert", message: error_message, vc: vc)
}
}
}
break

case .failure:
print(response.error ?? "Fail")
self.presentAlertWithTitle(title: "Error!", message: (response.error?.localizedDescription)!, vc: vc)
break
}
}
case .failure(let error):
self.presentAlertWithTitle(title: "Error!", message: error.localizedDescription, vc: vc)
}
})
let urlString = "\(baseURL)\(header)"
let jsonData : Data = try! JSONSerialization.data(withJSONObject: parameter, options: .prettyPrinted)

let jsonString = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue)! as String

print("JSON Params->\(jsonString)")

let headers: HTTPHeaders = [
"Authorization": "XXXXXX",
"Accept": "application/json",
"Content-Type": "application/json"
]


let uploadUrl = try! URLRequest(url: URL(string:urlString)!, method: .post, headers: headers)
AF.upload(
multipartFormData: { (multiPart) in
var keys = [String]()

for (key, img) in images {
if let imageData = img.jpegData(compressionQuality: compressRatio) {
multiPart.append(imageData, withName: key, fileName: key+".png", mimeType: "image/png")
keys.append(key)
}
}

let jsonName = try! JSONSerialization.data(withJSONObject: ["count": keys.count], options: .prettyPrinted)

multiPart.append(jsonName, withName: "names")
multiPart.append(jsonData, withName: "data")
}, with: uploadUrl, encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON{ response in
if hud{
Loader.init().hide(delegate: vc)
}

switch response.result {
case .success(_):
print("Response->\(response.value)")

if response.value != nil {
let JSON = response.value! as AnyObject
let response = JSON["response"] as! NSDictionary

let success = response.value(forKey: "status")
let success_message = response.value(forKey: "success_message")
let error_message = response.value(forKey: "error_message")

if success as! String {
completion(response.replaceNullsWithBlanks() as NSDictionary, success_message as NSString, true)
} else {
print("Upload failed")
completion([:], error_message as NSString, false)

if alertMsg {
self.presentAlertWithTitle(title: "Alert", message: error_message, vc: vc)
}
}
}
break

case .failure:
print(response.error ?? "Fail")
self.presentAlertWithTitle(title: "Error!", message: (response.error?.localizedDescription)!, vc: vc)
break
}
}
case .failure(let error):
self.presentAlertWithTitle(title: "Error!", message: error.localizedDescription, vc: vc)
}
})
Anyone know what's causing it?
6 replies