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

Update nodejs module for initial forge release. #1

Merged
merged 5 commits into from
May 1, 2012
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
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.1.0 2012-04-30 Nan Liu <[email protected]>
* Initial publish of module.
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright (C) 2012 Puppet Labs Inc

Puppet Labs can be contacted at: [email protected]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
12 changes: 12 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name 'puppetlabs-nodejs'
version '0.1.0'
source 'git://github.com/puppetlabs/puppetlabs-nodejs'
author 'puppetlabs'
license 'Apache 2.0'
summary 'Nodejs & NPM Puppet Module'
description 'Nodejs & NPM Puppet Module.'
project_page 'https://github.com/puppetlabs/puppetlabs-nodejs'

## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
'puppetlabs/stdlib', '>= 1.0.0'
35 changes: 35 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'rubygems'
require 'rake'
require 'rspec/core/rake_task'

task :default do
system("rake -T")
end

task :specs => [:spec]

desc "Run all rspec-puppet tests"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--color']
# ignores fixtures directory.
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
end

desc "Build puppet module package"
task :build do
# This will be deprecated once puppet-module is a face.
begin
Gem::Specification.find_by_name('puppet-module')
rescue Gem::LoadError, NoMethodError
require 'puppet/face'
pmod = Puppet::Face['module', :current]
pmod.build('./')
end
end

desc "Check puppet manifests with puppet-lint"
task :lint do
# This requires pull request: https://github.com/rodjek/puppet-lint/pull/81
system("puppet-lint manifests")
system("puppet-lint tests")
end
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
before => Package['nodejs'],
}
}

default: {
fail("Class nodejs does not support $::operatingsystem")
}
}

package { 'nodejs':
Expand All @@ -46,7 +50,7 @@

# npm installation is a hack since there's no packages:
exec { 'install_npm':
command => 'curl http://npmjs.org/install.sh | sed "s/<\/dev\/tty//g" > /tmp/install_$$.sh; chmod 755 /tmp/install_$$.sh; /tmp/install_$$.sh',
command => 'curl http://npmjs.org/install.sh | sed "s/<\/dev\/tty//g" > /tmp/install_$$.sh; chmod 755 /tmp/install_$$.sh; /tmp/install_$$.sh',
unless => 'which npm',
path => $::path,
logoutput => 'on_failure',
Expand Down
117 changes: 117 additions & 0 deletions spec/fixtures/unit/puppet/provider/pakages/npm/npm_global
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"dependencies": {
"express": {
"version": "2.5.9",
"dependencies": {
"connect": {
"version": "1.8.7",
"dependencies": {
"formidable": {
"version": "1.0.9"
}
}
},
"mime": {
"version": "1.2.4"
},
"qs": {
"version": "0.4.2"
},
"mkdirp": {
"version": "0.3.0"
}
}
},
"npm": {
"version": "1.1.15",
"dependencies": {
"semver": {
"version": "1.0.13"
},
"ini": {
"version": "1.0.2"
},
"slide": {
"version": "1.1.3"
},
"abbrev": {
"version": "1.0.3"
},
"graceful-fs": {
"version": "1.1.8"
},
"minimatch": {
"version": "0.2.2"
},
"nopt": {
"version": "1.0.10"
},
"node-uuid": {
"version": "1.3.3"
},
"proto-list": {
"version": "1.0.0"
},
"rimraf": {
"version": "2.0.1"
},
"request": {
"version": "2.9.153"
},
"which": {
"version": "1.0.5"
},
"tar": {
"version": "0.1.13"
},
"fstream": {
"version": "0.1.18"
},
"block-stream": {
"version": "0.0.5"
},
"inherits": {
"version": "1.0.0",
"from": "git://github.com/isaacs/inherits"
},
"mkdirp": {
"version": "0.3.0"
},
"read": {
"version": "0.0.1"
},
"lru-cache": {
"version": "1.0.5"
},
"node-gyp": {
"version": "0.3.9",
"dependencies": {
"ansi": {
"version": "0.0.4"
},
"glob": {
"version": "3.1.9"
}
}
},
"fstream-npm": {
"version": "0.0.4",
"dependencies": {
"fstream-ignore": {
"version": "0.0.5"
}
}
},
"uid-number": {
"version": "0.0.3"
},
"archy": {
"version": "0.0.2"
},
"chownr": {
"version": "0.0.1"
}
}
}
}
}
57 changes: 57 additions & 0 deletions spec/puppetlabs_spec/files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'fileutils'
require 'tempfile'
require 'pathname'

# A support module for testing files.
module PuppetlabsSpec::Files
# This code exists only to support tests that run as root, pretty much.
# Once they have finally been eliminated this can all go... --daniel 2011-04-08
def self.in_tmp(path)
tempdir = Dir.tmpdir

Pathname.new(path).ascend do |dir|
return true if File.identical?(tempdir, dir)
end

false
end

def self.cleanup
$global_tempfiles ||= []
while path = $global_tempfiles.pop do
fail "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path)

begin
FileUtils.rm_r path, :secure => true
rescue Errno::ENOENT
# nothing to do
end
end
end

def make_absolute(path)
path = File.expand_path(path)
path[0] = 'c' if Puppet.features.microsoft_windows?
path
end

def tmpfilename(name)
# Generate a temporary file, just for the name...
source = Tempfile.new(name)
path = source.path
source.close!

# ...record it for cleanup,
$global_tempfiles ||= []
$global_tempfiles << File.expand_path(path)

# ...and bam.
path
end

def tmpdir(name)
path = tmpfilename(name)
FileUtils.mkdir_p(path)
path
end
end
49 changes: 49 additions & 0 deletions spec/puppetlabs_spec/fixtures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This module provides some helper methods to assist with fixtures. It's
# methods are designed to help when you have a conforming fixture layout so we
# get project consistency.
module PuppetlabsSpec::Fixtures

# Returns the joined path of the global FIXTURE_DIR plus any path given to it
def fixtures(*rest)
File.join(PuppetlabsSpec::FIXTURE_DIR, *rest)
end

# Returns the path to your relative fixture dir. So if your spec test is
# <project>/spec/unit/facter/foo_spec.rb then your relative dir will be
# <project>/spec/fixture/unit/facter/foo
def my_fixture_dir
callers = caller
while line = callers.shift do
next unless found = line.match(%r{/spec/(.*)_spec\.rb:})
return fixtures(found[1])
end
fail "sorry, I couldn't work out your path from the caller stack!"
end

# Given a name, returns the full path of a file from your relative fixture
# dir as returned by my_fixture_dir.
def my_fixture(name)
file = File.join(my_fixture_dir, name)
unless File.readable? file then
fail "fixture '#{name}' for #{my_fixture_dir} is not readable"
end
return file
end

# Return the contents of the file using read when given a name. Uses
# my_fixture to work out the relative path.
def my_fixture_read(name)
File.read(my_fixture(name))
end

# Provides a block mechanism for iterating across the files in your fixture
# area.
def my_fixtures(glob = '*', flags = 0)
files = Dir.glob(File.join(my_fixture_dir, glob), flags)
unless files.length > 0 then
fail "fixture '#{glob}' for #{my_fixture_dir} had no files!"
end
block_given? and files.each do |file| yield file end
files
end
end
Loading