Skip to content

Commit

Permalink
remove dependency on node
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) committed Oct 11, 2024
1 parent 63ca0a2 commit 6f46a0f
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 1,615 deletions.
5 changes: 3 additions & 2 deletions dsc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dsc/src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ pub fn resource(subcommand: &ResourceSubCommand, stdin: &Option<String>) {
fn list_resources(dsc: &mut DscManager, resource_name: &Option<String>, adapter_name: &Option<String>, description: &Option<String>, tags: &Option<Vec<String>>, format: &Option<OutputFormat>) {
let mut write_table = false;
let mut table = Table::new(&["Type", "Kind", "Version", "Caps", "RequireAdapter", "Description"]);
if format.is_none() && io::stdin().is_terminal() {
if format.is_none() && io::stdout().is_terminal() {
// write as table if format is not specified and interactive
write_table = true;
}
Expand Down Expand Up @@ -580,7 +580,7 @@ fn list_resources(dsc: &mut DscManager, resource_name: &Option<String>, adapter_
};
write_output(&json, format);
// insert newline separating instances if writing to console
if io::stdin().is_terminal() { println!(); }
if io::stdout().is_terminal() { println!(); }
}
}

Expand Down
2 changes: 1 addition & 1 deletion dsc/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub fn write_output(json: &str, format: &Option<OutputFormat>) {
let mut is_json = true;
let mut output_format = format.clone();
let mut syntax_color = false;
if std::io::stdin().is_terminal() {
if std::io::stdout().is_terminal() {
syntax_color = true;
if output_format.is_none() {
output_format = Some(OutputFormat::Yaml);
Expand Down
5 changes: 3 additions & 2 deletions dsc_lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dsc_lib/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Statement {
/// This function will return an error if the underlying parser fails to initialize.
pub fn new() -> Result<Self, DscError> {
let mut parser = Parser::new();
parser.set_language(&tree_sitter_dscexpression::language())?;
parser.set_language(&tree_sitter_dscexpression::LANGUAGE.into())?;
let function_dispatcher = FunctionDispatcher::new();
Ok(Self {
parser,
Expand Down
5 changes: 3 additions & 2 deletions tools/test_group_resource/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions tree-sitter-dscexpression/.npmrc

This file was deleted.

5 changes: 3 additions & 2 deletions tree-sitter-dscexpression/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tree-sitter-dscexpression/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.24.3"
tree-sitter-language = "0.1.2"

[build-dependencies]
cc = "1.1"
cc = "1.1.29"
21 changes: 0 additions & 21 deletions tree-sitter-dscexpression/binding.gyp

This file was deleted.

48 changes: 5 additions & 43 deletions tree-sitter-dscexpression/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,10 @@ function Invoke-NativeCommand($cmd) {

$env:TREE_SITTER_VERBOSE=1

if ($null -eq (Get-Command npm -ErrorAction Ignore)) {
Write-Host 'Installing Node'

if ($IsWindows) {
winget install OpenJS.NodeJS.LTS
}
elseif ($IsMacOS) {
brew install node
}
else {
sudo apt-get install nodejs
sudo apt-get install npm
}
}

if ($null -ne $env:TF_BUILD) {
npm ci --omit:optional --registry https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/npm/registry/
}
else {
npm install --omit:optional --registry https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/npm/registry/
}

#npm list tree-sitter-cli
#if ($LASTEXITCODE -ne 0) {
# npm ci tree-sitter-cli --omit=optional
#}

#npm install -g node-gyp

if ($UpdatePackages) {
if (!$IsWindows) {
throw "This switch only works on Windows"
}

rm ./package-lock.json
rm -r ./node_modules
npm cache clean --force
npm logout
vsts-npm-auth -config .npmrc -F -V
npm install --omit:optional --force --verbose --registry https://registry.npmjs.org/ #--registry https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/npm/registry/
if ($null -eq (Get-Command tree-sitter)) {
cargo install tree-sitter-cli
}

Invoke-NativeCommand 'npx node-gyp configure'
Invoke-NativeCommand 'npx tree-sitter generate --build'
Invoke-NativeCommand 'npx tree-sitter test'
Invoke-NativeCommand 'tree-sitter init --update'
Invoke-NativeCommand 'tree-sitter generate --build'
Invoke-NativeCommand 'tree-sitter test'
Loading

0 comments on commit 6f46a0f

Please sign in to comment.